diff --git a/examples/cpp/configuration/ConfigurationPubSubTypes.cxx b/examples/cpp/configuration/ConfigurationPubSubTypes.cxx index 2c0854fb8bd..da5b125986f 100644 --- a/examples/cpp/configuration/ConfigurationPubSubTypes.cxx +++ b/examples/cpp/configuration/ConfigurationPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; ConfigurationPubSubType::ConfigurationPubSubType() { - setName("Configuration"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Configuration::getMaxCdrSerializedSize()); -#else - Configuration_max_cdr_typesize; -#endif + set_name("Configuration"); + uint32_t type_size = Configuration_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Configuration_max_key_cdr_typesize > 16 ? Configuration_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Configuration_max_key_cdr_typesize > 16 ? Configuration_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ConfigurationPubSubType::~ConfigurationPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ConfigurationPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Configuration* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool ConfigurationPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ConfigurationPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool ConfigurationPubSubType::deserialize( Configuration* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool ConfigurationPubSubType::deserialize( return true; } -std::function ConfigurationPubSubType::getSerializedSizeProvider( +uint32_t ConfigurationPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ConfigurationPubSubType::createData() +void* ConfigurationPubSubType::create_data() { return reinterpret_cast(new Configuration()); } -void ConfigurationPubSubType::deleteData( +void ConfigurationPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ConfigurationPubSubType::getKey( +bool ConfigurationPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Configuration data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ConfigurationPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool ConfigurationPubSubType::getKey( const Configuration* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Configuration_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Configuration_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/configuration/ConfigurationPubSubTypes.hpp b/examples/cpp/configuration/ConfigurationPubSubTypes.hpp index f5e4f1ca1f0..a1aa60218ed 100644 --- a/examples/cpp/configuration/ConfigurationPubSubTypes.hpp +++ b/examples/cpp/configuration/ConfigurationPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "Configuration.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated Configuration is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class ConfigurationPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class ConfigurationPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class ConfigurationPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/content_filter/HelloWorldPubSubTypes.cxx b/examples/cpp/content_filter/HelloWorldPubSubTypes.cxx index 38393dbf8c9..f9a6f740dbf 100644 --- a/examples/cpp/content_filter/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/content_filter/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() { - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), HelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/content_filter/HelloWorldPubSubTypes.hpp b/examples/cpp/content_filter/HelloWorldPubSubTypes.hpp index 556d4c05ecf..c9b0647aef5 100644 --- a/examples/cpp/content_filter/HelloWorldPubSubTypes.hpp +++ b/examples/cpp/content_filter/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/custom_payload_pool/HelloWorldPubSubTypes.cxx b/examples/cpp/custom_payload_pool/HelloWorldPubSubTypes.cxx index 38393dbf8c9..f9a6f740dbf 100644 --- a/examples/cpp/custom_payload_pool/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/custom_payload_pool/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() { - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), HelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/custom_payload_pool/HelloWorldPubSubTypes.hpp b/examples/cpp/custom_payload_pool/HelloWorldPubSubTypes.hpp index 556d4c05ecf..c9b0647aef5 100644 --- a/examples/cpp/custom_payload_pool/HelloWorldPubSubTypes.hpp +++ b/examples/cpp/custom_payload_pool/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp index c91b27a4c30..4820797b3cf 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp @@ -87,7 +87,7 @@ bool HelloWorldPublisher::init() return false; } - topic_ = mp_participant->create_topic("DDSDynHelloWorldTopic", m_type->getName(), TOPIC_QOS_DEFAULT); + topic_ = mp_participant->create_topic("DDSDynHelloWorldTopic", m_type->get_name(), TOPIC_QOS_DEFAULT); if (topic_ == nullptr) { diff --git a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp index f65d324a2cf..7dd61ab172f 100644 --- a/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp +++ b/examples/cpp/dds/DynamicHelloWorldExample/HelloWorldSubscriber.cpp @@ -149,7 +149,7 @@ void HelloWorldSubscriber::initialize_entities() //CREATE THE TOPIC Topic* topic = mp_participant->create_topic( "DDSDynHelloWorldTopic", - m_type->getName(), + m_type->get_name(), TOPIC_QOS_DEFAULT); if (topic == nullptr) diff --git a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPubSubTypes.cxx b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPubSubTypes.cxx index 38393dbf8c9..f9a6f740dbf 100644 --- a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() { - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), HelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPubSubTypes.hpp b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPubSubTypes.hpp index 75830b9c78b..8937b288ac5 100644 --- a/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPubSubTypes.hpp +++ b/examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPubSubTypes.cxx b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPubSubTypes.cxx index 38393dbf8c9..f9a6f740dbf 100644 --- a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() { - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), HelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPubSubTypes.hpp b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPubSubTypes.hpp index 556d4c05ecf..c9b0647aef5 100644 --- a/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPubSubTypes.hpp +++ b/examples/cpp/dds/HelloWorldExampleSharedMem/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPubSubTypes.cxx b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPubSubTypes.cxx index 38393dbf8c9..f9a6f740dbf 100644 --- a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() { - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), HelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPubSubTypes.hpp b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPubSubTypes.hpp index 556d4c05ecf..c9b0647aef5 100644 --- a/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPubSubTypes.hpp +++ b/examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/dds/Keys/samplePubSubTypes.cxx b/examples/cpp/dds/Keys/samplePubSubTypes.cxx index 7bde4db2c54..a773370ace4 100644 --- a/examples/cpp/dds/Keys/samplePubSubTypes.cxx +++ b/examples/cpp/dds/Keys/samplePubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; samplePubSubType::samplePubSubType() { - setName("sample"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sample::getMaxCdrSerializedSize()); -#else - sample_max_cdr_typesize; -#endif + set_name("sample"); + uint32_t type_size = sample_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = sample_max_key_cdr_typesize > 16 ? sample_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = sample_max_key_cdr_typesize > 16 ? sample_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } samplePubSubType::~samplePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool samplePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const sample* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool samplePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool samplePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool samplePubSubType::deserialize( sample* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool samplePubSubType::deserialize( return true; } -std::function samplePubSubType::getSerializedSizeProvider( +uint32_t samplePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* samplePubSubType::createData() +void* samplePubSubType::create_data() { return reinterpret_cast(new sample()); } -void samplePubSubType::deleteData( +void samplePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool samplePubSubType::getKey( +bool samplePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + sample data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool samplePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool samplePubSubType::getKey( const sample* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), sample_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || sample_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/dds/Keys/samplePubSubTypes.hpp b/examples/cpp/dds/Keys/samplePubSubTypes.hpp index 9ef5e577788..6d7ba563666 100644 --- a/examples/cpp/dds/Keys/samplePubSubTypes.hpp +++ b/examples/cpp/dds/Keys/samplePubSubTypes.hpp @@ -32,10 +32,10 @@ #include "sample.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated sample is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class samplePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class samplePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class samplePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPubSubTypes.cxx b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPubSubTypes.cxx index d971e2e4f36..adbd9673905 100644 --- a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPubSubTypes.cxx +++ b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; LoanableHelloWorldPubSubType::LoanableHelloWorldPubSubType() { - setName("LoanableHelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(LoanableHelloWorld::getMaxCdrSerializedSize()); -#else - LoanableHelloWorld_max_cdr_typesize; -#endif + set_name("LoanableHelloWorld"); + uint32_t type_size = LoanableHelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = LoanableHelloWorld_max_key_cdr_typesize > 16 ? LoanableHelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = LoanableHelloWorld_max_key_cdr_typesize > 16 ? LoanableHelloWorld_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } LoanableHelloWorldPubSubType::~LoanableHelloWorldPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool LoanableHelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const LoanableHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool LoanableHelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool LoanableHelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool LoanableHelloWorldPubSubType::deserialize( LoanableHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool LoanableHelloWorldPubSubType::deserialize( return true; } -std::function LoanableHelloWorldPubSubType::getSerializedSizeProvider( +uint32_t LoanableHelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* LoanableHelloWorldPubSubType::createData() +void* LoanableHelloWorldPubSubType::create_data() { return reinterpret_cast(new LoanableHelloWorld()); } -void LoanableHelloWorldPubSubType::deleteData( +void LoanableHelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool LoanableHelloWorldPubSubType::getKey( +bool LoanableHelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + LoanableHelloWorld data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool LoanableHelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool LoanableHelloWorldPubSubType::getKey( const LoanableHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), LoanableHelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || LoanableHelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPubSubTypes.hpp b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPubSubTypes.hpp index 3aed39a714c..d6d5f5c0a16 100644 --- a/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPubSubTypes.hpp +++ b/examples/cpp/dds/WriterLoansExample/LoanableHelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "LoanableHelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated LoanableHelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER #ifndef SWIG @@ -87,38 +87,30 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -133,10 +125,6 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -163,11 +151,12 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 260ULL == diff --git a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPubSubTypes.cxx b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPubSubTypes.cxx index d971e2e4f36..adbd9673905 100644 --- a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPubSubTypes.cxx +++ b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; LoanableHelloWorldPubSubType::LoanableHelloWorldPubSubType() { - setName("LoanableHelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(LoanableHelloWorld::getMaxCdrSerializedSize()); -#else - LoanableHelloWorld_max_cdr_typesize; -#endif + set_name("LoanableHelloWorld"); + uint32_t type_size = LoanableHelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = LoanableHelloWorld_max_key_cdr_typesize > 16 ? LoanableHelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = LoanableHelloWorld_max_key_cdr_typesize > 16 ? LoanableHelloWorld_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } LoanableHelloWorldPubSubType::~LoanableHelloWorldPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool LoanableHelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const LoanableHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool LoanableHelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool LoanableHelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool LoanableHelloWorldPubSubType::deserialize( LoanableHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool LoanableHelloWorldPubSubType::deserialize( return true; } -std::function LoanableHelloWorldPubSubType::getSerializedSizeProvider( +uint32_t LoanableHelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* LoanableHelloWorldPubSubType::createData() +void* LoanableHelloWorldPubSubType::create_data() { return reinterpret_cast(new LoanableHelloWorld()); } -void LoanableHelloWorldPubSubType::deleteData( +void LoanableHelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool LoanableHelloWorldPubSubType::getKey( +bool LoanableHelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + LoanableHelloWorld data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool LoanableHelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool LoanableHelloWorldPubSubType::getKey( const LoanableHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), LoanableHelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || LoanableHelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPubSubTypes.hpp b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPubSubTypes.hpp index 3aed39a714c..d6d5f5c0a16 100644 --- a/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPubSubTypes.hpp +++ b/examples/cpp/dds/ZeroCopyExample/LoanableHelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "LoanableHelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated LoanableHelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER #ifndef SWIG @@ -87,38 +87,30 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -133,10 +125,6 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -163,11 +151,12 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 260ULL == diff --git a/examples/cpp/delivery_mechanisms/DeliveryMechanismsPubSubTypes.cxx b/examples/cpp/delivery_mechanisms/DeliveryMechanismsPubSubTypes.cxx index 1525521fa8b..cb3e2b18d4d 100644 --- a/examples/cpp/delivery_mechanisms/DeliveryMechanismsPubSubTypes.cxx +++ b/examples/cpp/delivery_mechanisms/DeliveryMechanismsPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; DeliveryMechanismsPubSubType::DeliveryMechanismsPubSubType() { - setName("DeliveryMechanisms"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DeliveryMechanisms::getMaxCdrSerializedSize()); -#else - DeliveryMechanisms_max_cdr_typesize; -#endif + set_name("DeliveryMechanisms"); + uint32_t type_size = DeliveryMechanisms_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DeliveryMechanisms_max_key_cdr_typesize > 16 ? DeliveryMechanisms_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = DeliveryMechanisms_max_key_cdr_typesize > 16 ? DeliveryMechanisms_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DeliveryMechanismsPubSubType::~DeliveryMechanismsPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DeliveryMechanismsPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const DeliveryMechanisms* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool DeliveryMechanismsPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DeliveryMechanismsPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool DeliveryMechanismsPubSubType::deserialize( DeliveryMechanisms* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool DeliveryMechanismsPubSubType::deserialize( return true; } -std::function DeliveryMechanismsPubSubType::getSerializedSizeProvider( +uint32_t DeliveryMechanismsPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* DeliveryMechanismsPubSubType::createData() +void* DeliveryMechanismsPubSubType::create_data() { return reinterpret_cast(new DeliveryMechanisms()); } -void DeliveryMechanismsPubSubType::deleteData( +void DeliveryMechanismsPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool DeliveryMechanismsPubSubType::getKey( +bool DeliveryMechanismsPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + DeliveryMechanisms data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool DeliveryMechanismsPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool DeliveryMechanismsPubSubType::getKey( const DeliveryMechanisms* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), DeliveryMechanisms_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || DeliveryMechanisms_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/delivery_mechanisms/DeliveryMechanismsPubSubTypes.hpp b/examples/cpp/delivery_mechanisms/DeliveryMechanismsPubSubTypes.hpp index 6fd9210c569..af03ba7d1d0 100644 --- a/examples/cpp/delivery_mechanisms/DeliveryMechanismsPubSubTypes.hpp +++ b/examples/cpp/delivery_mechanisms/DeliveryMechanismsPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "DeliveryMechanisms.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated DeliveryMechanisms is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER #ifndef SWIG @@ -87,38 +87,30 @@ class DeliveryMechanismsPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -133,10 +125,6 @@ class DeliveryMechanismsPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -163,11 +151,12 @@ class DeliveryMechanismsPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 36ULL == diff --git a/examples/cpp/delivery_mechanisms/PubSubApp.cpp b/examples/cpp/delivery_mechanisms/PubSubApp.cpp index eab6be79312..3e2ac3c429b 100644 --- a/examples/cpp/delivery_mechanisms/PubSubApp.cpp +++ b/examples/cpp/delivery_mechanisms/PubSubApp.cpp @@ -68,7 +68,7 @@ PubSubApp::PubSubApp( , stop_(false) { // Check that the generated type fulfils example constraints: it is plain and bounded - if (!type_->is_plain() || !type_->is_bounded()) + if (!type_->is_plain(eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION) || !type_->is_bounded()) { throw std::runtime_error( "Example generated type does not fulfil the example constraints: it is not plain and/or bounded"); diff --git a/examples/cpp/delivery_mechanisms/PublisherApp.cpp b/examples/cpp/delivery_mechanisms/PublisherApp.cpp index ea100372f94..f3bf75413c6 100644 --- a/examples/cpp/delivery_mechanisms/PublisherApp.cpp +++ b/examples/cpp/delivery_mechanisms/PublisherApp.cpp @@ -60,7 +60,7 @@ PublisherApp::PublisherApp( , stop_(false) { // Check that the generated type fulfils example constraints: it is plain and bounded - if (!type_->is_plain() || !type_->is_bounded()) + if (!type_->is_plain(eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION) || !type_->is_bounded()) { throw std::runtime_error( "Example generated type does not fulfil the example constraints: it is not plain and/or bounded"); diff --git a/examples/cpp/delivery_mechanisms/SubscriberApp.cpp b/examples/cpp/delivery_mechanisms/SubscriberApp.cpp index 1c2a7d4d520..05751563b2d 100644 --- a/examples/cpp/delivery_mechanisms/SubscriberApp.cpp +++ b/examples/cpp/delivery_mechanisms/SubscriberApp.cpp @@ -59,7 +59,7 @@ SubscriberApp::SubscriberApp( , stop_(false) { // Check that the generated type fulfils example constraints: it is plain and bounded - if (!type_->is_plain() || !type_->is_bounded()) + if (!type_->is_plain(eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION) || !type_->is_bounded()) { throw std::runtime_error( "Example generated type does not fulfil the example constraints: it is not plain and/or bounded"); diff --git a/examples/cpp/discovery_server/HelloWorldPubSubTypes.cxx b/examples/cpp/discovery_server/HelloWorldPubSubTypes.cxx index 38393dbf8c9..f9a6f740dbf 100644 --- a/examples/cpp/discovery_server/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/discovery_server/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() { - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), HelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/discovery_server/HelloWorldPubSubTypes.hpp b/examples/cpp/discovery_server/HelloWorldPubSubTypes.hpp index 556d4c05ecf..c9b0647aef5 100644 --- a/examples/cpp/discovery_server/HelloWorldPubSubTypes.hpp +++ b/examples/cpp/discovery_server/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/flow_control/FlowControl.hpp b/examples/cpp/flow_control/FlowControl.hpp index 9a543be80fc..b77bb425968 100644 --- a/examples/cpp/flow_control/FlowControl.hpp +++ b/examples/cpp/flow_control/FlowControl.hpp @@ -221,4 +221,6 @@ class FlowControl }; -#endif // FAST_DDS_GENERATED__FLOWCONTROL_HPP +#endif // _FAST_DDS_GENERATED_FLOWCONTROL_HPP_ + + diff --git a/examples/cpp/flow_control/FlowControlCdrAux.hpp b/examples/cpp/flow_control/FlowControlCdrAux.hpp index 596b199d4c0..6526c6bd434 100644 --- a/examples/cpp/flow_control/FlowControlCdrAux.hpp +++ b/examples/cpp/flow_control/FlowControlCdrAux.hpp @@ -43,3 +43,4 @@ eProsima_user_DllExport void serialize_key( } // namespace eprosima #endif // FAST_DDS_GENERATED__FLOWCONTROLCDRAUX_HPP + diff --git a/examples/cpp/flow_control/FlowControlCdrAux.ipp b/examples/cpp/flow_control/FlowControlCdrAux.ipp index 481f6e2135f..6130cc70756 100644 --- a/examples/cpp/flow_control/FlowControlCdrAux.ipp +++ b/examples/cpp/flow_control/FlowControlCdrAux.ipp @@ -123,3 +123,4 @@ void serialize_key( } // namespace eprosima #endif // FAST_DDS_GENERATED__FLOWCONTROLCDRAUX_IPP + diff --git a/examples/cpp/flow_control/FlowControlPubSubTypes.cxx b/examples/cpp/flow_control/FlowControlPubSubTypes.cxx index 6bacf3ded72..f4681d8334e 100644 --- a/examples/cpp/flow_control/FlowControlPubSubTypes.cxx +++ b/examples/cpp/flow_control/FlowControlPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; FlowControlPubSubType::FlowControlPubSubType() { - setName("FlowControl"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FlowControl::getMaxCdrSerializedSize()); -#else - FlowControl_max_cdr_typesize; -#endif + set_name("FlowControl"); + uint32_t type_size = FlowControl_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FlowControl_max_key_cdr_typesize > 16 ? FlowControl_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FlowControl_max_key_cdr_typesize > 16 ? FlowControl_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FlowControlPubSubType::~FlowControlPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FlowControlPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FlowControl* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool FlowControlPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FlowControlPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool FlowControlPubSubType::deserialize( FlowControl* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool FlowControlPubSubType::deserialize( return true; } -std::function FlowControlPubSubType::getSerializedSizeProvider( +uint32_t FlowControlPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* FlowControlPubSubType::createData() +void* FlowControlPubSubType::create_data() { return reinterpret_cast(new FlowControl()); } -void FlowControlPubSubType::deleteData( +void FlowControlPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FlowControlPubSubType::getKey( +bool FlowControlPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FlowControl data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FlowControlPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool FlowControlPubSubType::getKey( const FlowControl* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FlowControl_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FlowControl_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/flow_control/FlowControlPubSubTypes.hpp b/examples/cpp/flow_control/FlowControlPubSubTypes.hpp index 65c48d35fd6..8b3edb55737 100644 --- a/examples/cpp/flow_control/FlowControlPubSubTypes.hpp +++ b/examples/cpp/flow_control/FlowControlPubSubTypes.hpp @@ -13,13 +13,13 @@ // limitations under the License. /*! - - * @file FlowControlPubSubTypes.h + * @file FlowControlPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ + #ifndef FAST_DDS_GENERATED__FLOWCONTROL_PUBSUBTYPES_HPP #define FAST_DDS_GENERATED__FLOWCONTROL_PUBSUBTYPES_HPP @@ -32,10 +32,10 @@ #include "FlowControl.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated FlowControl is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class FlowControlPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,13 +92,9 @@ class FlowControlPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,9 +112,12 @@ class FlowControlPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; #endif // FAST_DDS_GENERATED__FLOWCONTROL_PUBSUBTYPES_HPP + diff --git a/examples/cpp/flow_control/FlowControlTypeObjectSupport.hpp b/examples/cpp/flow_control/FlowControlTypeObjectSupport.hpp index c0ebc8c665d..338791494ce 100644 --- a/examples/cpp/flow_control/FlowControlTypeObjectSupport.hpp +++ b/examples/cpp/flow_control/FlowControlTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_FLOWCONTROL_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_FLOWCONTROL_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__FLOWCONTROL_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__FLOWCONTROL_TYPE_OBJECT_SUPPORT_HPP #include @@ -53,4 +53,4 @@ eProsima_user_DllExport void register_FlowControl_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_FLOWCONTROL_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__FLOWCONTROL_TYPE_OBJECT_SUPPORT_HPP diff --git a/examples/cpp/hello_world/HelloWorldPubSubTypes.cxx b/examples/cpp/hello_world/HelloWorldPubSubTypes.cxx index 38393dbf8c9..f9a6f740dbf 100644 --- a/examples/cpp/hello_world/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/hello_world/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() { - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), HelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/hello_world/HelloWorldPubSubTypes.hpp b/examples/cpp/hello_world/HelloWorldPubSubTypes.hpp index 556d4c05ecf..c9b0647aef5 100644 --- a/examples/cpp/hello_world/HelloWorldPubSubTypes.hpp +++ b/examples/cpp/hello_world/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/request_reply/types/CalculatorPubSubTypes.cxx b/examples/cpp/request_reply/types/CalculatorPubSubTypes.cxx index 28b085a472b..850e82a69c9 100644 --- a/examples/cpp/request_reply/types/CalculatorPubSubTypes.cxx +++ b/examples/cpp/request_reply/types/CalculatorPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; CalculatorRequestTypePubSubType::CalculatorRequestTypePubSubType() { - setName("CalculatorRequestType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CalculatorRequestType::getMaxCdrSerializedSize()); -#else - CalculatorRequestType_max_cdr_typesize; -#endif + set_name("CalculatorRequestType"); + uint32_t type_size = CalculatorRequestType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = CalculatorRequestType_max_key_cdr_typesize > 16 ? CalculatorRequestType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = CalculatorRequestType_max_key_cdr_typesize > 16 ? CalculatorRequestType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CalculatorRequestTypePubSubType::~CalculatorRequestTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CalculatorRequestTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CalculatorRequestType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool CalculatorRequestTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CalculatorRequestTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool CalculatorRequestTypePubSubType::deserialize( CalculatorRequestType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool CalculatorRequestTypePubSubType::deserialize( return true; } -std::function CalculatorRequestTypePubSubType::getSerializedSizeProvider( +uint32_t CalculatorRequestTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* CalculatorRequestTypePubSubType::createData() +void* CalculatorRequestTypePubSubType::create_data() { return reinterpret_cast(new CalculatorRequestType()); } -void CalculatorRequestTypePubSubType::deleteData( +void CalculatorRequestTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CalculatorRequestTypePubSubType::getKey( +bool CalculatorRequestTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CalculatorRequestType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CalculatorRequestTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool CalculatorRequestTypePubSubType::getKey( const CalculatorRequestType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), CalculatorRequestType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || CalculatorRequestType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void CalculatorRequestTypePubSubType::register_type_object_representation() CalculatorReplyTypePubSubType::CalculatorReplyTypePubSubType() { - setName("CalculatorReplyType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CalculatorReplyType::getMaxCdrSerializedSize()); -#else - CalculatorReplyType_max_cdr_typesize; -#endif + set_name("CalculatorReplyType"); + uint32_t type_size = CalculatorReplyType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = CalculatorReplyType_max_key_cdr_typesize > 16 ? CalculatorReplyType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = CalculatorReplyType_max_key_cdr_typesize > 16 ? CalculatorReplyType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CalculatorReplyTypePubSubType::~CalculatorReplyTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CalculatorReplyTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CalculatorReplyType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool CalculatorReplyTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CalculatorReplyTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool CalculatorReplyTypePubSubType::deserialize( CalculatorReplyType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool CalculatorReplyTypePubSubType::deserialize( return true; } -std::function CalculatorReplyTypePubSubType::getSerializedSizeProvider( +uint32_t CalculatorReplyTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* CalculatorReplyTypePubSubType::createData() +void* CalculatorReplyTypePubSubType::create_data() { return reinterpret_cast(new CalculatorReplyType()); } -void CalculatorReplyTypePubSubType::deleteData( +void CalculatorReplyTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CalculatorReplyTypePubSubType::getKey( +bool CalculatorReplyTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CalculatorReplyType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CalculatorReplyTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool CalculatorReplyTypePubSubType::getKey( const CalculatorReplyType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), CalculatorReplyType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || CalculatorReplyType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/request_reply/types/CalculatorPubSubTypes.hpp b/examples/cpp/request_reply/types/CalculatorPubSubTypes.hpp index 946ca0be8a8..4114f7bc08c 100644 --- a/examples/cpp/request_reply/types/CalculatorPubSubTypes.hpp +++ b/examples/cpp/request_reply/types/CalculatorPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "Calculator.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated Calculator is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class CalculatorRequestTypePubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class CalculatorRequestTypePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class CalculatorRequestTypePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -145,38 +135,30 @@ class CalculatorReplyTypePubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -191,10 +173,6 @@ class CalculatorReplyTypePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,8 +193,10 @@ class CalculatorReplyTypePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/security/HelloWorldPubSubTypes.cxx b/examples/cpp/security/HelloWorldPubSubTypes.cxx index 38393dbf8c9..f9a6f740dbf 100644 --- a/examples/cpp/security/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/security/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() { - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), HelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/security/HelloWorldPubSubTypes.hpp b/examples/cpp/security/HelloWorldPubSubTypes.hpp index 556d4c05ecf..c9b0647aef5 100644 --- a/examples/cpp/security/HelloWorldPubSubTypes.hpp +++ b/examples/cpp/security/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/examples/cpp/static_edp_discovery/HelloWorldPubSubTypes.cxx b/examples/cpp/static_edp_discovery/HelloWorldPubSubTypes.cxx index 38393dbf8c9..f9a6f740dbf 100644 --- a/examples/cpp/static_edp_discovery/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/static_edp_discovery/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() { - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), HelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/examples/cpp/static_edp_discovery/HelloWorldPubSubTypes.hpp b/examples/cpp/static_edp_discovery/HelloWorldPubSubTypes.hpp index 556d4c05ecf..c9b0647aef5 100644 --- a/examples/cpp/static_edp_discovery/HelloWorldPubSubTypes.hpp +++ b/examples/cpp/static_edp_discovery/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/include/fastdds/config.hpp.in b/include/fastdds/config.hpp.in index 508897f88e6..eb65636c8f3 100644 --- a/include/fastdds/config.hpp.in +++ b/include/fastdds/config.hpp.in @@ -20,7 +20,7 @@ #define FASTDDS_VERSION_MICRO @PROJECT_VERSION_PATCH@ #define FASTDDS_VERSION_STR "@PROJECT_VERSION@" -#define GEN_API_VER 2 +#define FASTDDS_GEN_API_VER 3 // C++20 support defines #ifndef HAVE_CXX20 diff --git a/include/fastdds/dds/topic/TopicDataType.hpp b/include/fastdds/dds/topic/TopicDataType.hpp index ea1173f5476..c27875a73da 100644 --- a/include/fastdds/dds/topic/TopicDataType.hpp +++ b/include/fastdds/dds/topic/TopicDataType.hpp @@ -64,26 +64,12 @@ class TopicDataType /** * @brief Constructor */ - FASTDDS_EXPORTED_API TopicDataType(); + FASTDDS_EXPORTED_API TopicDataType() = default; /** * @brief Destructor */ - FASTDDS_EXPORTED_API virtual ~TopicDataType(); - - /** - * Serialize method, it should be implemented by the user, since it is abstract. - * It is VERY IMPORTANT that the user sets the SerializedPayload length correctly. - * - * @param [in] data Pointer to the data - * @param [out] payload Pointer to the payload - * @return True if correct. - */ - // TODO(jlbueno) Remove when Fast DDS-Gen is updated - // FASTDDS_TODO_BEFORE(3, 0, "Remove this overload") - FASTDDS_EXPORTED_API virtual bool serialize( - const void* const data, - fastdds::rtps::SerializedPayload_t* payload) = 0; + FASTDDS_EXPORTED_API virtual ~TopicDataType() = default; /** * Serialize method, it should be implemented by the user, since it is abstract. If not implemented, this method @@ -97,8 +83,8 @@ class TopicDataType */ FASTDDS_EXPORTED_API virtual bool serialize( const void* const data, - fastdds::rtps::SerializedPayload_t* payload, - DataRepresentationId_t data_representation); + rtps::SerializedPayload_t& payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) = 0; /** * Deserialize method, it should be implemented by the user, since it is abstract. @@ -108,44 +94,48 @@ class TopicDataType * @return True if correct. */ FASTDDS_EXPORTED_API virtual bool deserialize( - fastdds::rtps::SerializedPayload_t* payload, + rtps::SerializedPayload_t& payload, void* data) = 0; /*! - * @brief Returns a function which can be used to calculate the serialized size of the provided data. - * - * @param [in] data Pointer to data. - * @return Functor which calculates the serialized size of the data. - */ - // FASTDDS_TODO_BEFORE(3, 0, "Remove this overload") - FASTDDS_EXPORTED_API virtual std::function getSerializedSizeProvider( - const void* const data) = 0; - - /*! - * @brief Returns a function which can be used to calculate the serialized size of the provided data. + * @brief Calculates the serialized size of the provided data. * * @param [in] data Pointer to data. * @param [in] data_representation Representation that should be used for calculating the serialized size. - * @return Functor which calculates the serialized size of the data. + * @return Serialized size of the data. */ - FASTDDS_EXPORTED_API virtual std::function getSerializedSizeProvider( + FASTDDS_EXPORTED_API virtual uint32_t calculate_serialized_size( const void* const data, - DataRepresentationId_t data_representation); + eprosima::fastdds::dds::DataRepresentationId_t data_representation) = 0; /** * Create a Data Type. * * @return Void pointer to the created object. */ - FASTDDS_EXPORTED_API virtual void* createData() = 0; + FASTDDS_EXPORTED_API virtual void* create_data() = 0; + /** * Remove a previously created object. * * @param data Pointer to the created Data. */ - FASTDDS_EXPORTED_API virtual void deleteData( + FASTDDS_EXPORTED_API virtual void delete_data( void* data) = 0; + /** + * Get the key associated with the data. + * + * @param [in] payload Pointer to the payload containing the data. + * @param [out] ihandle Pointer to the Handle. + * @param [in] force_md5 Force MD5 checking. + * @return True if correct. + */ + FASTDDS_EXPORTED_API virtual bool compute_key( + rtps::SerializedPayload_t& payload, + rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) = 0; + /** * Get the key associated with the data. * @@ -154,9 +144,9 @@ class TopicDataType * @param [in] force_md5 Force MD5 checking. * @return True if correct. */ - FASTDDS_EXPORTED_API virtual bool getKey( + FASTDDS_EXPORTED_API virtual bool compute_key( const void* const data, - fastdds::rtps::InstanceHandle_t* ihandle, + rtps::InstanceHandle_t& ihandle, bool force_md5 = false) = 0; /** @@ -164,10 +154,21 @@ class TopicDataType * * @param nam Topic data type name */ - FASTDDS_EXPORTED_API inline void setName( - const char* nam) + FASTDDS_EXPORTED_API inline void set_name( + const std::string& nam) + { + topic_data_typename_ = nam; + } + + /** + * Set topic data type name + * + * @param nam Topic data type name + */ + FASTDDS_EXPORTED_API inline void set_name( + std::string&& nam) { - m_topicDataTypeName = std::string(nam); + topic_data_typename_ = std::move(nam); } /** @@ -175,9 +176,9 @@ class TopicDataType * * @return Topic data type name */ - FASTDDS_EXPORTED_API inline const char* getName() const + FASTDDS_EXPORTED_API inline const std::string& get_name() const { - return m_topicDataTypeName.c_str(); + return topic_data_typename_; } /** @@ -219,14 +220,6 @@ class TopicDataType return false; } - /** - * Checks if the type is plain when using default encoding. - */ - FASTDDS_EXPORTED_API virtual inline bool is_plain() const - { - return false; - } - /** * Checks if the type is plain when using a specific encoding. */ @@ -259,10 +252,10 @@ class TopicDataType //! Maximum serialized size of the type in bytes. //! If the type has unbounded fields, and therefore cannot have a maximum size, use 0. - uint32_t m_typeSize; + uint32_t max_serialized_type_size {0}; //! Indicates whether the method to obtain the key has been implemented. - bool m_isGetKeyDefined; + bool is_compute_key_provided {false}; protected: @@ -271,11 +264,9 @@ class TopicDataType private: //! Data Type Name. - std::string m_topicDataTypeName; + std::string topic_data_typename_; //TODO(XTypes) - bool auto_fill_type_information_; - - friend class fastdds::dds::TypeSupport; + bool auto_fill_type_information_ {true}; }; diff --git a/include/fastdds/dds/topic/TypeSupport.hpp b/include/fastdds/dds/topic/TypeSupport.hpp index f8d4ad5814a..94eff077b19 100644 --- a/include/fastdds/dds/topic/TypeSupport.hpp +++ b/include/fastdds/dds/topic/TypeSupport.hpp @@ -128,22 +128,7 @@ class TypeSupport : public std::shared_ptr */ FASTDDS_EXPORTED_API virtual const std::string& get_type_name() const { - return get()->m_topicDataTypeName; - } - - /** - * @brief Serializes the data - * - * @param data Pointer to data - * @param payload Pointer to payload - * @return true if it is serialized correctly, false if not - */ - - FASTDDS_EXPORTED_API virtual bool serialize( - const void* const data, - fastdds::rtps::SerializedPayload_t* payload) - { - return serialize(data, payload, DEFAULT_DATA_REPRESENTATION); + return get()->get_name(); } /** @@ -156,7 +141,7 @@ class TypeSupport : public std::shared_ptr */ FASTDDS_EXPORTED_API virtual bool serialize( const void* const data, - fastdds::rtps::SerializedPayload_t* payload, + fastdds::rtps::SerializedPayload_t& payload, DataRepresentationId_t data_representation); /** @@ -167,21 +152,9 @@ class TypeSupport : public std::shared_ptr * @return true if it is deserialized correctly, false if not */ FASTDDS_EXPORTED_API virtual bool deserialize( - fastdds::rtps::SerializedPayload_t* payload, + fastdds::rtps::SerializedPayload_t& payload, void* data); - /*! - * @brief Returns a function which can be used to calculate the serialized size of the provided data. - * - * @param [in] data Pointer to data. - * @return Functor which calculates the serialized size of the data. - */ - FASTDDS_EXPORTED_API virtual std::function get_serialized_size_provider( - const void* const data) - { - return get_serialized_size_provider(data, DEFAULT_DATA_REPRESENTATION); - } - /*! * @brief Returns a function which can be used to calculate the serialized size of the provided data. * @@ -189,11 +162,11 @@ class TypeSupport : public std::shared_ptr * @param [in] data_representation Representation that should be used for calculating the serialized size. * @return Functor which calculates the serialized size of the data. */ - FASTDDS_EXPORTED_API virtual std::function get_serialized_size_provider( + FASTDDS_EXPORTED_API virtual uint32_t calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return get()->getSerializedSizeProvider(data, data_representation); + return get()->calculate_serialized_size(data, data_representation); } /** @@ -203,7 +176,7 @@ class TypeSupport : public std::shared_ptr */ FASTDDS_EXPORTED_API virtual void* create_data() { - return get()->createData(); + return get()->create_data(); } /** @@ -214,32 +187,48 @@ class TypeSupport : public std::shared_ptr FASTDDS_EXPORTED_API virtual void delete_data( void* data) { - return get()->deleteData(data); + return get()->delete_data(data); } /** * @brief Getter for the data key * - * @param data Pointer to data + * @param data Pointer to serialized payload containing the data. + * @param i_handle InstanceHandle pointer to store the key + * @param force_md5 boolean to force md5 (default: false) + * @return true if the key is returned, false if not + */ + FASTDDS_EXPORTED_API virtual bool compute_key( + const void* const data, + InstanceHandle_t& i_handle, + bool force_md5 = false) + { + return get()->compute_key(data, i_handle, force_md5); + } + + /** + * @brief Getter for the data key + * + * @param payload Pointer to data * @param i_handle InstanceHandle pointer to store the key * @param force_md5 boolean to force md5 (default: false) * @return true if the key is returned, false if not */ - FASTDDS_EXPORTED_API virtual bool get_key( - void* data, - InstanceHandle_t* i_handle, + FASTDDS_EXPORTED_API virtual bool compute_key( + fastdds::rtps::SerializedPayload_t& payload, + InstanceHandle_t& i_handle, bool force_md5 = false) { - return get()->getKey(data, i_handle, force_md5); + return get()->compute_key(payload, i_handle, force_md5); } FASTDDS_EXPORTED_API virtual bool operator ==( const TypeSupport& type_support) { - return get()->m_typeSize == type_support->m_typeSize - && get()->m_isGetKeyDefined == type_support->m_isGetKeyDefined - && get()->m_topicDataTypeName == type_support->m_topicDataTypeName - && get()->type_identifiers_ == type_support->type_identifiers_; + return get()->max_serialized_type_size == type_support->max_serialized_type_size + && get()->is_compute_key_provided == type_support->is_compute_key_provided + && get()->get_name() == type_support->get_name() + && get()->type_identifiers() == type_support->type_identifiers(); } /** @@ -260,14 +249,6 @@ class TypeSupport : public std::shared_ptr return get()->is_bounded(); } - /** - * Checks if the type is plain when using default encoding. - */ - FASTDDS_EXPORTED_API virtual inline bool is_plain() const - { - return is_plain(DataRepresentationId_t::XCDR_DATA_REPRESENTATION); - } - /** * Checks if the type is plain when using a specific encoding. */ diff --git a/include/fastdds/dds/xtypes/dynamic_types/DynamicPubSubType.hpp b/include/fastdds/dds/xtypes/dynamic_types/DynamicPubSubType.hpp index 3746ad287ff..8445e6ae1cc 100644 --- a/include/fastdds/dds/xtypes/dynamic_types/DynamicPubSubType.hpp +++ b/include/fastdds/dds/xtypes/dynamic_types/DynamicPubSubType.hpp @@ -56,14 +56,14 @@ class DynamicPubSubType : public virtual eprosima::fastdds::dds::TopicDataType * @return pointer to the new object * @remark Ownership is transferred. This object must be removed using @ref deleteData */ - FASTDDS_EXPORTED_API void* createData() override; + FASTDDS_EXPORTED_API void* create_data() override; /* * Deletes an object previously allocated via @ref createData * @param data pointer to the object to be deleted * @remark Ownership is transferred. This object must be allocated using @ref createData */ - FASTDDS_EXPORTED_API void deleteData ( + FASTDDS_EXPORTED_API void delete_data ( void* data) override; /* @@ -73,7 +73,7 @@ class DynamicPubSubType : public virtual eprosima::fastdds::dds::TopicDataType * @return bool specifying success */ FASTDDS_EXPORTED_API bool deserialize ( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; /* @@ -82,6 +82,18 @@ class DynamicPubSubType : public virtual eprosima::fastdds::dds::TopicDataType */ FASTDDS_EXPORTED_API traits::ref_type get_dynamic_type() const noexcept; + /* + * Calculate the key associated to a given object + * @param data payload containing the serialized object whose key is calculated + * @param ihandle @ref eprosima::fastdds::rtps::InstanceHandle_t to fill in + * @param force_md5 use always md5 even if key payload footprint is smaller than the hash + * @return bool specifying success + */ + FASTDDS_EXPORTED_API bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + /* * Calculate the key associated to a given object * @param data object whose key is calculated @@ -89,46 +101,31 @@ class DynamicPubSubType : public virtual eprosima::fastdds::dds::TopicDataType * @param force_md5 use always md5 even if key payload footprint is smaller than the hash * @return bool specifying success */ - FASTDDS_EXPORTED_API bool getKey( + FASTDDS_EXPORTED_API bool compute_key( const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t* ihandle, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; /* * Provide a functor that calculates a specified object serialized size - * @param data object whose payload footprint to calculate + * @param[in] data object whose payload footprint to calculate + * @param [in] data_representation Representation that should be used for calculating the serialized size. * @return functor that calculates the size */ - // FASTDDS_TODO_BEFORE(3, 0, "Remove this overload") - FASTDDS_EXPORTED_API std::function getSerializedSizeProvider( - const void* const data) override; - - FASTDDS_EXPORTED_API std::function getSerializedSizeProvider( + FASTDDS_EXPORTED_API uint32_t calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) override; /* * Serialize an object into a given payload - * @param data object to serialize - * @param payload @ref eprosima::fastdds::rtps::SerializedPayload_t to fill in - * @return bool specifying success - */ - FASTDDS_EXPORTED_API bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - /* - * Serialize an object into a given payload - * @param data object to serialize - * @param payload @ref eprosima::fastdds::rtps::SerializedPayload_t to fill in + * @param[in] data object to serialize + * @param[out] payload @ref eprosima::fastdds::rtps::SerializedPayload_t to fill in + * @param [in] data_representation Representation that should be used to encode the data into the payload. * @return bool specifying success */ FASTDDS_EXPORTED_API bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, fastdds::dds::DataRepresentationId_t data_representation) override; /* diff --git a/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobjectPubSubTypes.hpp b/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobjectPubSubTypes.hpp index fd95cb9b942..4ca6575f1b9 100644 --- a/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobjectPubSubTypes.hpp +++ b/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobjectPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "dds_xtypes_typeobject.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated dds_xtypes_typeobject is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER namespace eprosima { @@ -178,38 +178,30 @@ class StringSTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -224,10 +216,6 @@ class StringSTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -254,11 +242,12 @@ class StringSTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 1ULL == @@ -324,38 +313,30 @@ class StringLTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -370,10 +351,6 @@ class StringLTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -400,11 +377,12 @@ class StringLTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 4ULL == @@ -437,38 +415,30 @@ class PlainCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -483,10 +453,6 @@ class PlainCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -507,8 +473,10 @@ class PlainCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -528,38 +496,30 @@ class PlainSequenceSElemDefnPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -574,10 +534,6 @@ class PlainSequenceSElemDefnPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -598,8 +554,10 @@ class PlainSequenceSElemDefnPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -619,38 +577,30 @@ class PlainSequenceLElemDefnPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -665,10 +615,6 @@ class PlainSequenceLElemDefnPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -689,8 +635,10 @@ class PlainSequenceLElemDefnPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -710,38 +658,30 @@ class PlainArraySElemDefnPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -756,10 +696,6 @@ class PlainArraySElemDefnPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -780,8 +716,10 @@ class PlainArraySElemDefnPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -801,38 +739,30 @@ class PlainArrayLElemDefnPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -847,10 +777,6 @@ class PlainArrayLElemDefnPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -871,8 +797,10 @@ class PlainArrayLElemDefnPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -892,38 +820,30 @@ class PlainMapSTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -938,10 +858,6 @@ class PlainMapSTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -962,8 +878,10 @@ class PlainMapSTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -983,38 +901,30 @@ class PlainMapLTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1029,10 +939,6 @@ class PlainMapLTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1053,8 +959,10 @@ class PlainMapLTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1074,38 +982,30 @@ class StronglyConnectedComponentIdPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1120,10 +1020,6 @@ class StronglyConnectedComponentIdPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1144,8 +1040,10 @@ class StronglyConnectedComponentIdPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1165,38 +1063,30 @@ class ExtendedTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1211,10 +1101,6 @@ class ExtendedTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1235,8 +1121,10 @@ class ExtendedTypeDefnPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1256,38 +1144,30 @@ class DummyPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1302,10 +1182,6 @@ class DummyPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1332,11 +1208,12 @@ class DummyPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return true; @@ -1370,38 +1247,30 @@ class ExtendedAnnotationParameterValuePubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1416,10 +1285,6 @@ class ExtendedAnnotationParameterValuePubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1440,8 +1305,10 @@ class ExtendedAnnotationParameterValuePubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1462,38 +1329,30 @@ class AppliedAnnotationParameterPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1508,10 +1367,6 @@ class AppliedAnnotationParameterPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1532,8 +1387,10 @@ class AppliedAnnotationParameterPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector AppliedAnnotationParameterSeq; @@ -1554,38 +1411,30 @@ class AppliedAnnotationPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1600,10 +1449,6 @@ class AppliedAnnotationPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1624,8 +1469,10 @@ class AppliedAnnotationPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector AppliedAnnotationSeq; @@ -1646,38 +1493,30 @@ class AppliedVerbatimAnnotationPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1692,10 +1531,6 @@ class AppliedVerbatimAnnotationPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1716,8 +1551,10 @@ class AppliedVerbatimAnnotationPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1737,38 +1574,30 @@ class AppliedBuiltinMemberAnnotationsPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1783,10 +1612,6 @@ class AppliedBuiltinMemberAnnotationsPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1807,8 +1632,10 @@ class AppliedBuiltinMemberAnnotationsPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1828,38 +1655,30 @@ class CommonStructMemberPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1874,10 +1693,6 @@ class CommonStructMemberPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1898,8 +1713,10 @@ class CommonStructMemberPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1919,38 +1736,30 @@ class CompleteMemberDetailPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1965,10 +1774,6 @@ class CompleteMemberDetailPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1989,8 +1794,10 @@ class CompleteMemberDetailPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2043,38 +1850,30 @@ class MinimalMemberDetailPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2089,10 +1888,6 @@ class MinimalMemberDetailPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2119,11 +1914,12 @@ class MinimalMemberDetailPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 4ULL == @@ -2156,38 +1952,30 @@ class CompleteStructMemberPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2202,10 +1990,6 @@ class CompleteStructMemberPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2226,8 +2010,10 @@ class CompleteStructMemberPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector CompleteStructMemberSeq; @@ -2248,38 +2034,30 @@ class MinimalStructMemberPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2294,10 +2072,6 @@ class MinimalStructMemberPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2318,8 +2092,10 @@ class MinimalStructMemberPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector MinimalStructMemberSeq; @@ -2340,38 +2116,30 @@ class AppliedBuiltinTypeAnnotationsPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2386,10 +2154,6 @@ class AppliedBuiltinTypeAnnotationsPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2410,8 +2174,10 @@ class AppliedBuiltinTypeAnnotationsPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2431,38 +2197,30 @@ class MinimalTypeDetailPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2477,10 +2235,6 @@ class MinimalTypeDetailPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2507,11 +2261,12 @@ class MinimalTypeDetailPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return true; @@ -2540,38 +2295,30 @@ class CompleteTypeDetailPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2586,10 +2333,6 @@ class CompleteTypeDetailPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2610,8 +2353,10 @@ class CompleteTypeDetailPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2631,38 +2376,30 @@ class CompleteStructHeaderPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2677,10 +2414,6 @@ class CompleteStructHeaderPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2701,8 +2434,10 @@ class CompleteStructHeaderPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2722,38 +2457,30 @@ class MinimalStructHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2768,10 +2495,6 @@ class MinimalStructHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2792,8 +2515,10 @@ class MinimalStructHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2813,38 +2538,30 @@ class CompleteStructTypePubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2859,10 +2576,6 @@ class CompleteStructTypePubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2883,8 +2596,10 @@ class CompleteStructTypePubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2904,38 +2619,30 @@ class MinimalStructTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2950,10 +2657,6 @@ class MinimalStructTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2974,8 +2677,10 @@ class MinimalStructTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector UnionCaseLabelSeq; @@ -2996,38 +2701,30 @@ class CommonUnionMemberPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3042,10 +2739,6 @@ class CommonUnionMemberPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3066,8 +2759,10 @@ class CommonUnionMemberPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3087,38 +2782,30 @@ class CompleteUnionMemberPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3133,10 +2820,6 @@ class CompleteUnionMemberPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3157,8 +2840,10 @@ class CompleteUnionMemberPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector CompleteUnionMemberSeq; @@ -3179,38 +2864,30 @@ class MinimalUnionMemberPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3225,10 +2902,6 @@ class MinimalUnionMemberPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3249,8 +2922,10 @@ class MinimalUnionMemberPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector MinimalUnionMemberSeq; @@ -3271,38 +2946,30 @@ class CommonDiscriminatorMemberPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3317,10 +2984,6 @@ class CommonDiscriminatorMemberPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3341,8 +3004,10 @@ class CommonDiscriminatorMemberPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3362,38 +3027,30 @@ class CompleteDiscriminatorMemberPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3408,10 +3065,6 @@ class CompleteDiscriminatorMemberPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3432,8 +3085,10 @@ class CompleteDiscriminatorMemberPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3453,38 +3108,30 @@ class MinimalDiscriminatorMemberPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3499,10 +3146,6 @@ class MinimalDiscriminatorMemberPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3523,8 +3166,10 @@ class MinimalDiscriminatorMemberPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3544,38 +3189,30 @@ class CompleteUnionHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3590,10 +3227,6 @@ class CompleteUnionHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3614,8 +3247,10 @@ class CompleteUnionHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3635,38 +3270,30 @@ class MinimalUnionHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3681,10 +3308,6 @@ class MinimalUnionHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3705,8 +3328,10 @@ class MinimalUnionHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3726,38 +3351,30 @@ class CompleteUnionTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3772,10 +3389,6 @@ class CompleteUnionTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3796,8 +3409,10 @@ class CompleteUnionTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3817,38 +3432,30 @@ class MinimalUnionTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3863,10 +3470,6 @@ class MinimalUnionTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3887,8 +3490,10 @@ class MinimalUnionTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3908,38 +3513,30 @@ class CommonAnnotationParameterPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3954,10 +3551,6 @@ class CommonAnnotationParameterPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3978,8 +3571,10 @@ class CommonAnnotationParameterPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3999,38 +3594,30 @@ class CompleteAnnotationParameterPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4045,10 +3632,6 @@ class CompleteAnnotationParameterPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4069,8 +3652,10 @@ class CompleteAnnotationParameterPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector CompleteAnnotationParameterSeq; @@ -4091,38 +3676,30 @@ class MinimalAnnotationParameterPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4137,10 +3714,6 @@ class MinimalAnnotationParameterPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4161,8 +3734,10 @@ class MinimalAnnotationParameterPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector MinimalAnnotationParameterSeq; @@ -4183,38 +3758,30 @@ class CompleteAnnotationHeaderPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4229,10 +3796,6 @@ class CompleteAnnotationHeaderPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4253,8 +3816,10 @@ class CompleteAnnotationHeaderPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4274,38 +3839,30 @@ class MinimalAnnotationHeaderPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4320,10 +3877,6 @@ class MinimalAnnotationHeaderPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4344,8 +3897,10 @@ class MinimalAnnotationHeaderPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4365,38 +3920,30 @@ class CompleteAnnotationTypePubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4411,10 +3958,6 @@ class CompleteAnnotationTypePubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4435,8 +3978,10 @@ class CompleteAnnotationTypePubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4456,38 +4001,30 @@ class MinimalAnnotationTypePubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4502,10 +4039,6 @@ class MinimalAnnotationTypePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4526,8 +4059,10 @@ class MinimalAnnotationTypePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4547,38 +4082,30 @@ class CommonAliasBodyPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4593,10 +4120,6 @@ class CommonAliasBodyPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4617,8 +4140,10 @@ class CommonAliasBodyPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4638,38 +4163,30 @@ class CompleteAliasBodyPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4684,10 +4201,6 @@ class CompleteAliasBodyPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4708,8 +4221,10 @@ class CompleteAliasBodyPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4729,38 +4244,30 @@ class MinimalAliasBodyPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4775,10 +4282,6 @@ class MinimalAliasBodyPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4799,8 +4302,10 @@ class MinimalAliasBodyPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4820,38 +4325,30 @@ class CompleteAliasHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4866,10 +4363,6 @@ class CompleteAliasHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4890,8 +4383,10 @@ class CompleteAliasHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4911,38 +4406,30 @@ class MinimalAliasHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4957,10 +4444,6 @@ class MinimalAliasHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4981,8 +4464,10 @@ class MinimalAliasHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5002,38 +4487,30 @@ class CompleteAliasTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5048,10 +4525,6 @@ class CompleteAliasTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5072,8 +4545,10 @@ class CompleteAliasTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5093,38 +4568,30 @@ class MinimalAliasTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5139,10 +4606,6 @@ class MinimalAliasTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5163,8 +4626,10 @@ class MinimalAliasTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5184,38 +4649,30 @@ class CompleteElementDetailPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5230,10 +4687,6 @@ class CompleteElementDetailPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5254,8 +4707,10 @@ class CompleteElementDetailPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5275,38 +4730,30 @@ class CommonCollectionElementPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5321,10 +4768,6 @@ class CommonCollectionElementPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5345,8 +4788,10 @@ class CommonCollectionElementPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5366,38 +4811,30 @@ class CompleteCollectionElementPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5412,10 +4849,6 @@ class CompleteCollectionElementPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5436,8 +4869,10 @@ class CompleteCollectionElementPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5457,38 +4892,30 @@ class MinimalCollectionElementPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5503,10 +4930,6 @@ class MinimalCollectionElementPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5527,8 +4950,10 @@ class MinimalCollectionElementPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5581,38 +5006,30 @@ class CommonCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5627,10 +5044,6 @@ class CommonCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5657,11 +5070,12 @@ class CommonCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 4ULL == @@ -5694,38 +5108,30 @@ class CompleteCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5740,10 +5146,6 @@ class CompleteCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5764,8 +5166,10 @@ class CompleteCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5785,38 +5189,30 @@ class MinimalCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5831,10 +5227,6 @@ class MinimalCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5855,8 +5247,10 @@ class MinimalCollectionHeaderPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5876,38 +5270,30 @@ class CompleteSequenceTypePubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5922,10 +5308,6 @@ class CompleteSequenceTypePubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5946,8 +5328,10 @@ class CompleteSequenceTypePubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5967,38 +5351,30 @@ class MinimalSequenceTypePubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6013,10 +5389,6 @@ class MinimalSequenceTypePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6037,8 +5409,10 @@ class MinimalSequenceTypePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6058,38 +5432,30 @@ class CommonArrayHeaderPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6104,10 +5470,6 @@ class CommonArrayHeaderPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6128,8 +5490,10 @@ class CommonArrayHeaderPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6149,38 +5513,30 @@ class CompleteArrayHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6195,10 +5551,6 @@ class CompleteArrayHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6219,8 +5571,10 @@ class CompleteArrayHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6240,38 +5594,30 @@ class MinimalArrayHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6286,10 +5632,6 @@ class MinimalArrayHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6310,8 +5652,10 @@ class MinimalArrayHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6331,38 +5675,30 @@ class CompleteArrayTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6377,10 +5713,6 @@ class CompleteArrayTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6401,8 +5733,10 @@ class CompleteArrayTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6422,38 +5756,30 @@ class MinimalArrayTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6468,10 +5794,6 @@ class MinimalArrayTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6492,8 +5814,10 @@ class MinimalArrayTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6513,38 +5837,30 @@ class CompleteMapTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6559,10 +5875,6 @@ class CompleteMapTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6583,8 +5895,10 @@ class CompleteMapTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6604,38 +5918,30 @@ class MinimalMapTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6650,10 +5956,6 @@ class MinimalMapTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6674,8 +5976,10 @@ class MinimalMapTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef uint16_t BitBound; @@ -6696,38 +6000,30 @@ class CommonEnumeratedLiteralPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6742,10 +6038,6 @@ class CommonEnumeratedLiteralPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6766,8 +6058,10 @@ class CommonEnumeratedLiteralPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6787,38 +6081,30 @@ class CompleteEnumeratedLiteralPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6833,10 +6119,6 @@ class CompleteEnumeratedLiteralPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6857,8 +6139,10 @@ class CompleteEnumeratedLiteralPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector CompleteEnumeratedLiteralSeq; @@ -6879,38 +6163,30 @@ class MinimalEnumeratedLiteralPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6925,10 +6201,6 @@ class MinimalEnumeratedLiteralPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6949,8 +6221,10 @@ class MinimalEnumeratedLiteralPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector MinimalEnumeratedLiteralSeq; @@ -7004,38 +6278,30 @@ class CommonEnumeratedHeaderPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7050,10 +6316,6 @@ class CommonEnumeratedHeaderPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7080,11 +6342,12 @@ class CommonEnumeratedHeaderPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 2ULL == @@ -7117,38 +6380,30 @@ class CompleteEnumeratedHeaderPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7163,10 +6418,6 @@ class CompleteEnumeratedHeaderPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7187,8 +6438,10 @@ class CompleteEnumeratedHeaderPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7208,38 +6461,30 @@ class MinimalEnumeratedHeaderPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7254,10 +6499,6 @@ class MinimalEnumeratedHeaderPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7278,8 +6519,10 @@ class MinimalEnumeratedHeaderPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7299,38 +6542,30 @@ class CompleteEnumeratedTypePubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7345,10 +6580,6 @@ class CompleteEnumeratedTypePubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7369,8 +6600,10 @@ class CompleteEnumeratedTypePubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7390,38 +6623,30 @@ class MinimalEnumeratedTypePubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7436,10 +6661,6 @@ class MinimalEnumeratedTypePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7460,8 +6681,10 @@ class MinimalEnumeratedTypePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7481,38 +6704,30 @@ class CommonBitflagPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7527,10 +6742,6 @@ class CommonBitflagPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7551,8 +6762,10 @@ class CommonBitflagPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7572,38 +6785,30 @@ class CompleteBitflagPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7618,10 +6823,6 @@ class CompleteBitflagPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7642,8 +6843,10 @@ class CompleteBitflagPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector CompleteBitflagSeq; @@ -7664,38 +6867,30 @@ class MinimalBitflagPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7710,10 +6905,6 @@ class MinimalBitflagPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7734,8 +6925,10 @@ class MinimalBitflagPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector MinimalBitflagSeq; @@ -7789,38 +6982,30 @@ class CommonBitmaskHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7835,10 +7020,6 @@ class CommonBitmaskHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7865,11 +7046,12 @@ class CommonBitmaskHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 2ULL == @@ -7904,38 +7086,30 @@ class CompleteBitmaskTypePubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7950,10 +7124,6 @@ class CompleteBitmaskTypePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7974,8 +7144,10 @@ class CompleteBitmaskTypePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7995,38 +7167,30 @@ class MinimalBitmaskTypePubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8041,10 +7205,6 @@ class MinimalBitmaskTypePubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8065,8 +7225,10 @@ class MinimalBitmaskTypePubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8086,38 +7248,30 @@ class CommonBitfieldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8132,10 +7286,6 @@ class CommonBitfieldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8156,8 +7306,10 @@ class CommonBitfieldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8177,38 +7329,30 @@ class CompleteBitfieldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8223,10 +7367,6 @@ class CompleteBitfieldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8247,8 +7387,10 @@ class CompleteBitfieldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector CompleteBitfieldSeq; @@ -8269,38 +7411,30 @@ class MinimalBitfieldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8315,10 +7449,6 @@ class MinimalBitfieldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8339,8 +7469,10 @@ class MinimalBitfieldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector MinimalBitfieldSeq; @@ -8361,38 +7493,30 @@ class CompleteBitsetHeaderPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8407,10 +7531,6 @@ class CompleteBitsetHeaderPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8431,8 +7551,10 @@ class CompleteBitsetHeaderPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8452,38 +7574,30 @@ class MinimalBitsetHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8498,10 +7612,6 @@ class MinimalBitsetHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8522,8 +7632,10 @@ class MinimalBitsetHeaderPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8543,38 +7655,30 @@ class CompleteBitsetTypePubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8589,10 +7693,6 @@ class CompleteBitsetTypePubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8613,8 +7713,10 @@ class CompleteBitsetTypePubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8634,38 +7736,30 @@ class MinimalBitsetTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8680,10 +7774,6 @@ class MinimalBitsetTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8704,8 +7794,10 @@ class MinimalBitsetTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8725,38 +7817,30 @@ class CompleteExtendedTypePubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8771,10 +7855,6 @@ class CompleteExtendedTypePubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8795,8 +7875,10 @@ class CompleteExtendedTypePubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8817,38 +7899,30 @@ class MinimalExtendedTypePubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8863,10 +7937,6 @@ class MinimalExtendedTypePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8887,8 +7957,10 @@ class MinimalExtendedTypePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8912,38 +7984,30 @@ class TypeIdentifierTypeObjectPairPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8958,10 +8022,6 @@ class TypeIdentifierTypeObjectPairPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8982,8 +8042,10 @@ class TypeIdentifierTypeObjectPairPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector TypeIdentifierTypeObjectPairSeq; @@ -9004,38 +8066,30 @@ class TypeIdentifierPairPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9050,10 +8104,6 @@ class TypeIdentifierPairPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9074,8 +8124,10 @@ class TypeIdentifierPairPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector TypeIdentifierPairSeq; @@ -9096,38 +8148,30 @@ class TypeIdentfierWithSizePubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9142,10 +8186,6 @@ class TypeIdentfierWithSizePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9166,8 +8206,10 @@ class TypeIdentfierWithSizePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector TypeIdentfierWithSizeSeq; @@ -9188,38 +8230,30 @@ class TypeIdentifierWithDependenciesPubSubType : public eprosima::fastdds::dds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9234,10 +8268,6 @@ class TypeIdentifierWithDependenciesPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9258,8 +8288,10 @@ class TypeIdentifierWithDependenciesPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector TypeIdentifierWithDependenciesSeq; @@ -9280,38 +8312,30 @@ class TypeInformationPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9326,10 +8350,6 @@ class TypeInformationPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9350,8 +8370,10 @@ class TypeInformationPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector TypeInformationSeq; diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 027af6ae514..77ce4af23ba 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -85,7 +85,6 @@ set(${PROJECT_NAME}_source_files fastdds/topic/ContentFilteredTopicImpl.cpp fastdds/topic/qos/TopicQos.cpp fastdds/topic/Topic.cpp - fastdds/topic/TopicDataType.cpp fastdds/topic/TopicImpl.cpp fastdds/topic/TopicProxyFactory.cpp fastdds/topic/TypeSupport.cpp diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index 68b7dfea023..4d895f1b45e 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -279,7 +279,7 @@ SampleIdentity TypeLookupManager::get_type_dependencies( id = request->header().requestId(); } // Delete request data after sending - type.deleteData(request); + type.delete_data(request); return id; } @@ -303,7 +303,7 @@ SampleIdentity TypeLookupManager::get_types( id = request->header().requestId(); } // Delete request data after sending - type.deleteData(request); + type.delete_data(request); return id; } @@ -669,7 +669,7 @@ TypeLookup_Request* TypeLookupManager::create_request( const fastdds::rtps::GUID_t& type_server, TypeLookup_RequestPubSubType& pupsubtype) const { - TypeLookup_Request* request = static_cast(pupsubtype.createData()); + TypeLookup_Request* request = static_cast(pupsubtype.create_data()); request->header().instanceName() = get_instance_name(type_server); request->header().requestId().writer_guid(guid_rtps_2_dds(builtin_request_writer_->getGuid())); request->header().requestId().sequence_number(sequence_number_rtps_2_dds(request_seq_number_)); @@ -720,7 +720,7 @@ bool TypeLookupManager::send_impl( } // Serialize the message using the provided PubSubType - bool result = pubsubtype->serialize(&msg, &change->serializedPayload, + bool result = pubsubtype->serialize(&msg, change->serializedPayload, DataRepresentationId_t::XCDR2_DATA_REPRESENTATION); // If serialization was successful, update the change and add it to the WriterHistory if (result) @@ -798,7 +798,7 @@ bool TypeLookupManager::receive_impl( return false; } - bool result = pubsubtype->deserialize(&payload, &msg); + bool result = pubsubtype->deserialize(payload, &msg); payload.data = nullptr; return result; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index 91115d1bb27..05cd2735075 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -379,7 +379,7 @@ void TypeLookupRequestListener::answer_request( rpc::RemoteExceptionCode_t exception_code, TypeLookup_getTypeDependencies_Out& out) { - TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); + TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.create_data()); TypeLookup_getTypeDependencies_Result result; result.result(out); reply->return_value().getTypeDependencies(result); @@ -387,7 +387,7 @@ void TypeLookupRequestListener::answer_request( reply->header().remoteEx(exception_code); typelookup_manager_->send(*reply); - typelookup_manager_->reply_type_.deleteData(reply); + typelookup_manager_->reply_type_.delete_data(reply); } void TypeLookupRequestListener::answer_request( @@ -395,7 +395,7 @@ void TypeLookupRequestListener::answer_request( rpc::RemoteExceptionCode_t exception_code, TypeLookup_getTypes_Out& out) { - TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); + TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.create_data()); TypeLookup_getTypes_Result result; result.result(out); reply->return_value().getType(result); @@ -403,19 +403,19 @@ void TypeLookupRequestListener::answer_request( reply->header().remoteEx(exception_code); typelookup_manager_->send(*reply); - typelookup_manager_->reply_type_.deleteData(reply); + typelookup_manager_->reply_type_.delete_data(reply); } void TypeLookupRequestListener::answer_request( SampleIdentity request_id, rpc::RemoteExceptionCode_t exception_code) { - TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.createData()); + TypeLookup_Reply* reply = static_cast(typelookup_manager_->reply_type_.create_data()); reply->header().relatedRequestId(request_id); reply->header().remoteEx(exception_code); typelookup_manager_->send(*reply); - typelookup_manager_->reply_type_.deleteData(reply); + typelookup_manager_->reply_type_.delete_data(reply); } void TypeLookupRequestListener::on_new_cache_change_added( diff --git a/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypesPubSubTypes.cxx b/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypesPubSubTypes.cxx index 8f6eba8a973..47afc23994f 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypesPubSubTypes.cxx +++ b/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypesPubSubTypes.cxx @@ -39,49 +39,42 @@ namespace dds { namespace builtin { TypeLookup_getTypes_InPubSubType::TypeLookup_getTypes_InPubSubType() { - setName("eprosima::fastdds::dds::builtin::TypeLookup_getTypes_In"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeLookup_getTypes_In::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_dds_builtin_TypeLookup_getTypes_In_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::dds::builtin::TypeLookup_getTypes_In"); + uint32_t type_size = eprosima_fastdds_dds_builtin_TypeLookup_getTypes_In_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_builtin_TypeLookup_getTypes_In_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_getTypes_In_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_builtin_TypeLookup_getTypes_In_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_getTypes_In_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeLookup_getTypes_InPubSubType::~TypeLookup_getTypes_InPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeLookup_getTypes_InPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeLookup_getTypes_In* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -96,16 +89,12 @@ namespace builtin { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeLookup_getTypes_InPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -114,18 +103,14 @@ namespace builtin { TypeLookup_getTypes_In* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -138,52 +123,62 @@ namespace builtin { return true; } - std::function TypeLookup_getTypes_InPubSubType::getSerializedSizeProvider( + uint32_t TypeLookup_getTypes_InPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* TypeLookup_getTypes_InPubSubType::createData() + void* TypeLookup_getTypes_InPubSubType::create_data() { return reinterpret_cast(new TypeLookup_getTypes_In()); } - void TypeLookup_getTypes_InPubSubType::deleteData( + void TypeLookup_getTypes_InPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool TypeLookup_getTypes_InPubSubType::getKey( + bool TypeLookup_getTypes_InPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + TypeLookup_getTypes_In data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool TypeLookup_getTypes_InPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -191,35 +186,27 @@ namespace builtin { const TypeLookup_getTypes_In* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_builtin_TypeLookup_getTypes_In_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_builtin_TypeLookup_getTypes_In_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -233,49 +220,42 @@ namespace builtin { TypeLookup_getTypes_OutPubSubType::TypeLookup_getTypes_OutPubSubType() { - setName("eprosima::fastdds::dds::builtin::TypeLookup_getTypes_Out"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeLookup_getTypes_Out::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_dds_builtin_TypeLookup_getTypes_Out_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::dds::builtin::TypeLookup_getTypes_Out"); + uint32_t type_size = eprosima_fastdds_dds_builtin_TypeLookup_getTypes_Out_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_builtin_TypeLookup_getTypes_Out_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_getTypes_Out_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_builtin_TypeLookup_getTypes_Out_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_getTypes_Out_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeLookup_getTypes_OutPubSubType::~TypeLookup_getTypes_OutPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeLookup_getTypes_OutPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeLookup_getTypes_Out* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -290,16 +270,12 @@ namespace builtin { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeLookup_getTypes_OutPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -308,18 +284,14 @@ namespace builtin { TypeLookup_getTypes_Out* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -332,52 +304,62 @@ namespace builtin { return true; } - std::function TypeLookup_getTypes_OutPubSubType::getSerializedSizeProvider( + uint32_t TypeLookup_getTypes_OutPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* TypeLookup_getTypes_OutPubSubType::createData() + void* TypeLookup_getTypes_OutPubSubType::create_data() { return reinterpret_cast(new TypeLookup_getTypes_Out()); } - void TypeLookup_getTypes_OutPubSubType::deleteData( + void TypeLookup_getTypes_OutPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool TypeLookup_getTypes_OutPubSubType::getKey( + bool TypeLookup_getTypes_OutPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + TypeLookup_getTypes_Out data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool TypeLookup_getTypes_OutPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -385,35 +367,27 @@ namespace builtin { const TypeLookup_getTypes_Out* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_builtin_TypeLookup_getTypes_Out_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_builtin_TypeLookup_getTypes_Out_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -428,49 +402,42 @@ namespace builtin { TypeLookup_getTypeDependencies_InPubSubType::TypeLookup_getTypeDependencies_InPubSubType() { - setName("eprosima::fastdds::dds::builtin::TypeLookup_getTypeDependencies_In"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeLookup_getTypeDependencies_In::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_In_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::dds::builtin::TypeLookup_getTypeDependencies_In"); + uint32_t type_size = eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_In_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_In_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_In_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_In_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_In_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeLookup_getTypeDependencies_InPubSubType::~TypeLookup_getTypeDependencies_InPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeLookup_getTypeDependencies_InPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeLookup_getTypeDependencies_In* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -485,16 +452,12 @@ namespace builtin { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeLookup_getTypeDependencies_InPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -503,18 +466,14 @@ namespace builtin { TypeLookup_getTypeDependencies_In* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -527,52 +486,62 @@ namespace builtin { return true; } - std::function TypeLookup_getTypeDependencies_InPubSubType::getSerializedSizeProvider( + uint32_t TypeLookup_getTypeDependencies_InPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* TypeLookup_getTypeDependencies_InPubSubType::createData() + void* TypeLookup_getTypeDependencies_InPubSubType::create_data() { return reinterpret_cast(new TypeLookup_getTypeDependencies_In()); } - void TypeLookup_getTypeDependencies_InPubSubType::deleteData( + void TypeLookup_getTypeDependencies_InPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool TypeLookup_getTypeDependencies_InPubSubType::getKey( + bool TypeLookup_getTypeDependencies_InPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + TypeLookup_getTypeDependencies_In data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool TypeLookup_getTypeDependencies_InPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -580,35 +549,27 @@ namespace builtin { const TypeLookup_getTypeDependencies_In* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_In_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_In_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -622,49 +583,42 @@ namespace builtin { TypeLookup_getTypeDependencies_OutPubSubType::TypeLookup_getTypeDependencies_OutPubSubType() { - setName("eprosima::fastdds::dds::builtin::TypeLookup_getTypeDependencies_Out"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeLookup_getTypeDependencies_Out::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_Out_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::dds::builtin::TypeLookup_getTypeDependencies_Out"); + uint32_t type_size = eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_Out_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_Out_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_Out_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_Out_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_Out_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeLookup_getTypeDependencies_OutPubSubType::~TypeLookup_getTypeDependencies_OutPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeLookup_getTypeDependencies_OutPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeLookup_getTypeDependencies_Out* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -679,16 +633,12 @@ namespace builtin { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeLookup_getTypeDependencies_OutPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -697,18 +647,14 @@ namespace builtin { TypeLookup_getTypeDependencies_Out* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -721,52 +667,62 @@ namespace builtin { return true; } - std::function TypeLookup_getTypeDependencies_OutPubSubType::getSerializedSizeProvider( + uint32_t TypeLookup_getTypeDependencies_OutPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* TypeLookup_getTypeDependencies_OutPubSubType::createData() + void* TypeLookup_getTypeDependencies_OutPubSubType::create_data() { return reinterpret_cast(new TypeLookup_getTypeDependencies_Out()); } - void TypeLookup_getTypeDependencies_OutPubSubType::deleteData( + void TypeLookup_getTypeDependencies_OutPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool TypeLookup_getTypeDependencies_OutPubSubType::getKey( + bool TypeLookup_getTypeDependencies_OutPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + TypeLookup_getTypeDependencies_Out data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool TypeLookup_getTypeDependencies_OutPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -774,35 +730,27 @@ namespace builtin { const TypeLookup_getTypeDependencies_Out* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_Out_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_builtin_TypeLookup_getTypeDependencies_Out_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -818,49 +766,42 @@ namespace builtin { TypeLookup_RequestPubSubType::TypeLookup_RequestPubSubType() { - setName("eprosima::fastdds::dds::builtin::TypeLookup_Request"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeLookup_Request::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_dds_builtin_TypeLookup_Request_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::dds::builtin::TypeLookup_Request"); + uint32_t type_size = eprosima_fastdds_dds_builtin_TypeLookup_Request_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_builtin_TypeLookup_Request_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_Request_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_builtin_TypeLookup_Request_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_Request_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeLookup_RequestPubSubType::~TypeLookup_RequestPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeLookup_RequestPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeLookup_Request* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -875,16 +816,12 @@ namespace builtin { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeLookup_RequestPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -893,18 +830,14 @@ namespace builtin { TypeLookup_Request* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -917,52 +850,62 @@ namespace builtin { return true; } - std::function TypeLookup_RequestPubSubType::getSerializedSizeProvider( + uint32_t TypeLookup_RequestPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* TypeLookup_RequestPubSubType::createData() + void* TypeLookup_RequestPubSubType::create_data() { return reinterpret_cast(new TypeLookup_Request()); } - void TypeLookup_RequestPubSubType::deleteData( + void TypeLookup_RequestPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool TypeLookup_RequestPubSubType::getKey( + bool TypeLookup_RequestPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + TypeLookup_Request data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool TypeLookup_RequestPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -970,35 +913,27 @@ namespace builtin { const TypeLookup_Request* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_builtin_TypeLookup_Request_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_builtin_TypeLookup_Request_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1013,49 +948,42 @@ namespace builtin { TypeLookup_ReplyPubSubType::TypeLookup_ReplyPubSubType() { - setName("eprosima::fastdds::dds::builtin::TypeLookup_Reply"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeLookup_Reply::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_dds_builtin_TypeLookup_Reply_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::dds::builtin::TypeLookup_Reply"); + uint32_t type_size = eprosima_fastdds_dds_builtin_TypeLookup_Reply_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_builtin_TypeLookup_Reply_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_Reply_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_builtin_TypeLookup_Reply_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_builtin_TypeLookup_Reply_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeLookup_ReplyPubSubType::~TypeLookup_ReplyPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeLookup_ReplyPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeLookup_Reply* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1070,16 +998,12 @@ namespace builtin { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeLookup_ReplyPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1088,18 +1012,14 @@ namespace builtin { TypeLookup_Reply* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1112,52 +1032,62 @@ namespace builtin { return true; } - std::function TypeLookup_ReplyPubSubType::getSerializedSizeProvider( + uint32_t TypeLookup_ReplyPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* TypeLookup_ReplyPubSubType::createData() + void* TypeLookup_ReplyPubSubType::create_data() { return reinterpret_cast(new TypeLookup_Reply()); } - void TypeLookup_ReplyPubSubType::deleteData( + void TypeLookup_ReplyPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool TypeLookup_ReplyPubSubType::getKey( + bool TypeLookup_ReplyPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + TypeLookup_Reply data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool TypeLookup_ReplyPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1165,35 +1095,27 @@ namespace builtin { const TypeLookup_Reply* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_builtin_TypeLookup_Reply_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_builtin_TypeLookup_Reply_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypesPubSubTypes.hpp b/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypesPubSubTypes.hpp index 7361e8a76da..152db35ea63 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypesPubSubTypes.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypesPubSubTypes.hpp @@ -35,10 +35,10 @@ #include #include -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated TypeLookupTypes is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER namespace eprosima { @@ -66,38 +66,30 @@ namespace builtin eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -112,10 +104,6 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -136,8 +124,10 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -157,38 +147,30 @@ namespace builtin eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -203,10 +185,6 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -227,8 +205,10 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -249,38 +229,30 @@ namespace builtin eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -295,10 +267,6 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -319,8 +287,10 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -340,38 +310,30 @@ namespace builtin eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -386,10 +348,6 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -410,8 +368,10 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -433,38 +393,30 @@ namespace builtin eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -479,10 +431,6 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -503,8 +451,10 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -525,38 +475,30 @@ namespace builtin eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -571,10 +513,6 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -595,8 +533,10 @@ namespace builtin #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace builtin diff --git a/src/cpp/fastdds/builtin/type_lookup_service/detail/rpc_typesPubSubTypes.cxx b/src/cpp/fastdds/builtin/type_lookup_service/detail/rpc_typesPubSubTypes.cxx index d7a3435aba9..44f359afde4 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/detail/rpc_typesPubSubTypes.cxx +++ b/src/cpp/fastdds/builtin/type_lookup_service/detail/rpc_typesPubSubTypes.cxx @@ -38,49 +38,42 @@ namespace dds { EntityId_tPubSubType::EntityId_tPubSubType() { - setName("eprosima::fastdds::dds::EntityId_t"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(EntityId_t::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_EntityId_t_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::EntityId_t"); + uint32_t type_size = eprosima_fastdds_dds_EntityId_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_EntityId_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_EntityId_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_EntityId_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_EntityId_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EntityId_tPubSubType::~EntityId_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EntityId_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EntityId_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -95,16 +88,12 @@ bool EntityId_tPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EntityId_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -113,18 +102,14 @@ bool EntityId_tPubSubType::deserialize( EntityId_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -137,52 +122,62 @@ bool EntityId_tPubSubType::deserialize( return true; } -std::function EntityId_tPubSubType::getSerializedSizeProvider( +uint32_t EntityId_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* EntityId_tPubSubType::createData() +void* EntityId_tPubSubType::create_data() { return reinterpret_cast(new EntityId_t()); } -void EntityId_tPubSubType::deleteData( +void EntityId_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool EntityId_tPubSubType::getKey( +bool EntityId_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + EntityId_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool EntityId_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -190,35 +185,27 @@ bool EntityId_tPubSubType::getKey( const EntityId_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_EntityId_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_EntityId_t_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -232,49 +219,42 @@ void EntityId_tPubSubType::register_type_object_representation() GUID_tPubSubType::GUID_tPubSubType() { - setName("eprosima::fastdds::dds::GUID_t"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(GUID_t::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_GUID_t_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::GUID_t"); + uint32_t type_size = eprosima_fastdds_dds_GUID_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_GUID_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_GUID_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_GUID_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_GUID_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } GUID_tPubSubType::~GUID_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool GUID_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const GUID_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -289,16 +269,12 @@ bool GUID_tPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool GUID_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -307,18 +283,14 @@ bool GUID_tPubSubType::deserialize( GUID_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -331,52 +303,62 @@ bool GUID_tPubSubType::deserialize( return true; } -std::function GUID_tPubSubType::getSerializedSizeProvider( +uint32_t GUID_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* GUID_tPubSubType::createData() +void* GUID_tPubSubType::create_data() { return reinterpret_cast(new GUID_t()); } -void GUID_tPubSubType::deleteData( +void GUID_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool GUID_tPubSubType::getKey( +bool GUID_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + GUID_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool GUID_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -384,35 +366,27 @@ bool GUID_tPubSubType::getKey( const GUID_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_GUID_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_GUID_t_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -426,49 +400,42 @@ void GUID_tPubSubType::register_type_object_representation() SequenceNumber_tPubSubType::SequenceNumber_tPubSubType() { - setName("eprosima::fastdds::dds::SequenceNumber_t"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceNumber_t::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_SequenceNumber_t_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::SequenceNumber_t"); + uint32_t type_size = eprosima_fastdds_dds_SequenceNumber_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_SequenceNumber_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_SequenceNumber_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_SequenceNumber_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_SequenceNumber_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceNumber_tPubSubType::~SequenceNumber_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceNumber_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceNumber_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -483,16 +450,12 @@ bool SequenceNumber_tPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceNumber_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -501,18 +464,14 @@ bool SequenceNumber_tPubSubType::deserialize( SequenceNumber_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -525,52 +484,62 @@ bool SequenceNumber_tPubSubType::deserialize( return true; } -std::function SequenceNumber_tPubSubType::getSerializedSizeProvider( +uint32_t SequenceNumber_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* SequenceNumber_tPubSubType::createData() +void* SequenceNumber_tPubSubType::create_data() { return reinterpret_cast(new SequenceNumber_t()); } -void SequenceNumber_tPubSubType::deleteData( +void SequenceNumber_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceNumber_tPubSubType::getKey( +bool SequenceNumber_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceNumber_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceNumber_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -578,35 +547,27 @@ bool SequenceNumber_tPubSubType::getKey( const SequenceNumber_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_SequenceNumber_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_SequenceNumber_t_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -620,49 +581,42 @@ void SequenceNumber_tPubSubType::register_type_object_representation() SampleIdentityPubSubType::SampleIdentityPubSubType() { - setName("eprosima::fastdds::dds::SampleIdentity"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SampleIdentity::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_SampleIdentity_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::SampleIdentity"); + uint32_t type_size = eprosima_fastdds_dds_SampleIdentity_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_SampleIdentity_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_SampleIdentity_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_SampleIdentity_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_SampleIdentity_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SampleIdentityPubSubType::~SampleIdentityPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SampleIdentityPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SampleIdentity* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -677,16 +631,12 @@ bool SampleIdentityPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SampleIdentityPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -695,18 +645,14 @@ bool SampleIdentityPubSubType::deserialize( SampleIdentity* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -719,52 +665,62 @@ bool SampleIdentityPubSubType::deserialize( return true; } -std::function SampleIdentityPubSubType::getSerializedSizeProvider( +uint32_t SampleIdentityPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* SampleIdentityPubSubType::createData() +void* SampleIdentityPubSubType::create_data() { return reinterpret_cast(new SampleIdentity()); } -void SampleIdentityPubSubType::deleteData( +void SampleIdentityPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SampleIdentityPubSubType::getKey( +bool SampleIdentityPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SampleIdentity data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SampleIdentityPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -772,35 +728,27 @@ bool SampleIdentityPubSubType::getKey( const SampleIdentity* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_SampleIdentity_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_SampleIdentity_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -815,49 +763,42 @@ void SampleIdentityPubSubType::register_type_object_representation() namespace rpc { RequestHeaderPubSubType::RequestHeaderPubSubType() { - setName("eprosima::fastdds::dds::rpc::RequestHeader"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(RequestHeader::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_dds_rpc_RequestHeader_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::dds::rpc::RequestHeader"); + uint32_t type_size = eprosima_fastdds_dds_rpc_RequestHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_rpc_RequestHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_rpc_RequestHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_rpc_RequestHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_rpc_RequestHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } RequestHeaderPubSubType::~RequestHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool RequestHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const RequestHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -872,16 +813,12 @@ namespace rpc { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool RequestHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -890,18 +827,14 @@ namespace rpc { RequestHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -914,52 +847,62 @@ namespace rpc { return true; } - std::function RequestHeaderPubSubType::getSerializedSizeProvider( + uint32_t RequestHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* RequestHeaderPubSubType::createData() + 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* RequestHeaderPubSubType::create_data() { return reinterpret_cast(new RequestHeader()); } - void RequestHeaderPubSubType::deleteData( + void RequestHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool RequestHeaderPubSubType::getKey( + bool RequestHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + RequestHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool RequestHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -967,35 +910,27 @@ namespace rpc { const RequestHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_rpc_RequestHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_rpc_RequestHeader_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1009,49 +944,42 @@ namespace rpc { ReplyHeaderPubSubType::ReplyHeaderPubSubType() { - setName("eprosima::fastdds::dds::rpc::ReplyHeader"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(ReplyHeader::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_dds_rpc_ReplyHeader_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::dds::rpc::ReplyHeader"); + uint32_t type_size = eprosima_fastdds_dds_rpc_ReplyHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_rpc_ReplyHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_rpc_ReplyHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_rpc_ReplyHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_rpc_ReplyHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ReplyHeaderPubSubType::~ReplyHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ReplyHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ReplyHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1066,16 +994,12 @@ namespace rpc { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ReplyHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1084,18 +1008,14 @@ namespace rpc { ReplyHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1108,52 +1028,62 @@ namespace rpc { return true; } - std::function ReplyHeaderPubSubType::getSerializedSizeProvider( + uint32_t ReplyHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* ReplyHeaderPubSubType::createData() + 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* ReplyHeaderPubSubType::create_data() { return reinterpret_cast(new ReplyHeader()); } - void ReplyHeaderPubSubType::deleteData( + void ReplyHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool ReplyHeaderPubSubType::getKey( + bool ReplyHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + ReplyHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool ReplyHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1161,35 +1091,27 @@ namespace rpc { const ReplyHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_rpc_ReplyHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_rpc_ReplyHeader_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/detail/rpc_typesPubSubTypes.hpp b/src/cpp/fastdds/builtin/type_lookup_service/detail/rpc_typesPubSubTypes.hpp index 6d81093423e..8d685a273cf 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/detail/rpc_typesPubSubTypes.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/detail/rpc_typesPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "rpc_types.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated rpc_types is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER namespace eprosima { @@ -95,38 +95,30 @@ class EntityId_tPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -141,10 +133,6 @@ class EntityId_tPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -171,11 +159,12 @@ class EntityId_tPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 4ULL == @@ -241,38 +230,30 @@ class GUID_tPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -287,10 +268,6 @@ class GUID_tPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -317,11 +294,12 @@ class GUID_tPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 16ULL == @@ -387,38 +365,30 @@ class SequenceNumber_tPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -433,10 +403,6 @@ class SequenceNumber_tPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -463,11 +429,12 @@ class SequenceNumber_tPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 8ULL == @@ -533,38 +500,30 @@ class SampleIdentityPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -579,10 +538,6 @@ class SampleIdentityPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -609,11 +564,12 @@ class SampleIdentityPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 24ULL == @@ -653,38 +609,30 @@ namespace rpc eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -699,10 +647,6 @@ namespace rpc #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -723,8 +667,10 @@ namespace rpc #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -777,38 +723,30 @@ namespace rpc eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -823,10 +761,6 @@ namespace rpc #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -853,11 +787,12 @@ namespace rpc #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 28ULL == diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index 2eedc826720..17426b637fd 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -164,7 +164,7 @@ DataWriterImpl::DataWriterImpl( { EndpointAttributes endpoint_attributes; endpoint_attributes.endpointKind = WRITER; - endpoint_attributes.topicKind = type_->m_isGetKeyDefined ? WITH_KEY : NO_KEY; + endpoint_attributes.topicKind = type_->is_compute_key_provided ? WITH_KEY : NO_KEY; endpoint_attributes.setEntityID(qos_.endpoint().entity_id); endpoint_attributes.setUserDefinedID(qos_.endpoint().user_defined_id); fastdds::rtps::RTPSParticipantImpl::preprocess_endpoint_attributes( @@ -228,7 +228,7 @@ void DataWriterImpl::create_history( history_.reset(new DataWriterHistory( payload_pool, change_pool, get_topic_attributes(qos_, *topic_, type_), - type_->m_typeSize, + type_->max_serialized_type_size, qos_.endpoint().history_memory_policy, [this]( const InstanceHandle_t& handle) -> void @@ -246,7 +246,7 @@ ReturnCode_t DataWriterImpl::enable() auto topic_att = get_topic_attributes(qos_, *topic_, type_); auto history_att = DataWriterHistory::to_history_attributes( - topic_att, type_->m_typeSize, qos_.endpoint().history_memory_policy); + topic_att, type_->max_serialized_type_size, qos_.endpoint().history_memory_policy); pool_config_ = PoolConfig::from_history_attributes(history_att); // When the user requested PREALLOCATED_WITH_REALLOC, but we know the type cannot @@ -261,7 +261,7 @@ ReturnCode_t DataWriterImpl::enable() w_att.endpoint.durabilityKind = qos_.durability().durabilityKind(); w_att.endpoint.endpointKind = WRITER; w_att.endpoint.reliabilityKind = qos_.reliability().kind == RELIABLE_RELIABILITY_QOS ? RELIABLE : BEST_EFFORT; - w_att.endpoint.topicKind = type_->m_isGetKeyDefined ? WITH_KEY : NO_KEY; + w_att.endpoint.topicKind = type_->is_compute_key_provided ? WITH_KEY : NO_KEY; w_att.endpoint.multicastLocatorList = qos_.endpoint().multicast_locator_list; w_att.endpoint.unicastLocatorList = qos_.endpoint().unicast_locator_list; w_att.endpoint.remoteLocatorList = qos_.endpoint().remote_locator_list; @@ -500,7 +500,7 @@ DataWriterImpl::~DataWriterImpl() if (writer_ != nullptr) { - EPROSIMA_LOG_INFO(DATA_WRITER, guid().entityId << " in topic: " << type_->getName()); + EPROSIMA_LOG_INFO(DATA_WRITER, guid().entityId << " in topic: " << type_->get_name()); RTPSDomain::removeRTPSWriter(writer_); release_payload_pool(); } @@ -517,7 +517,8 @@ ReturnCode_t DataWriterImpl::loan_sample( microseconds(rtps::TimeConv::Time_t2MicroSecondsInt64(qos_.reliability().max_blocking_time)); // Type should be plain and have space for the representation header - if (!type_->is_plain(data_representation_) || SerializedPayload_t::representation_header_size > type_->m_typeSize) + if (!type_->is_plain(data_representation_) || + SerializedPayload_t::representation_header_size > type_->max_serialized_type_size) { return RETCODE_ILLEGAL_OPERATION; } @@ -541,11 +542,8 @@ ReturnCode_t DataWriterImpl::loan_sample( // Get one payload from the pool SerializedPayload_t payload; - uint32_t size = type_->m_typeSize; - if (!get_free_payload_from_pool([size]() - { - return size; - }, payload)) + uint32_t size = type_->max_serialized_type_size; + if (!get_free_payload_from_pool(size, payload)) { return RETCODE_OUT_OF_RESOURCES; } @@ -607,7 +605,8 @@ ReturnCode_t DataWriterImpl::discard_loan( void*& sample) { // Type should be plain and have space for the representation header - if (!type_->is_plain(data_representation_) || SerializedPayload_t::representation_header_size > type_->m_typeSize) + if (!type_->is_plain(data_representation_) || + SerializedPayload_t::representation_header_size > type_->max_serialized_type_size) { return RETCODE_ILLEGAL_OPERATION; } @@ -669,13 +668,13 @@ ReturnCode_t DataWriterImpl::check_write_preconditions( return RETCODE_NOT_ENABLED; } - if (type_.get()->m_isGetKeyDefined) + if (type_.get()->is_compute_key_provided) { bool is_key_protected = false; #if HAVE_SECURITY is_key_protected = writer_->getAttributes().security_attributes().is_key_protected; #endif // if HAVE_SECURITY - type_.get()->getKey(data, &instance_handle, is_key_protected); + type_.get()->compute_key(data, instance_handle, is_key_protected); } //Check if the Handle is different from the special value HANDLE_NIL and @@ -748,7 +747,7 @@ ReturnCode_t DataWriterImpl::check_instance_preconditions( return RETCODE_BAD_PARAMETER; } - if (!type_->m_isGetKeyDefined) + if (!type_->is_compute_key_provided) { EPROSIMA_LOG_ERROR(DATA_WRITER, "Topic is NO_KEY, operation not permitted"); return RETCODE_PRECONDITION_NOT_MET; @@ -764,7 +763,7 @@ ReturnCode_t DataWriterImpl::check_instance_preconditions( #if HAVE_SECURITY is_key_protected = writer_->getAttributes().security_attributes().is_key_protected; #endif // if HAVE_SECURITY - type_->getKey(data, &instance_handle, is_key_protected); + type_->compute_key(data, instance_handle, is_key_protected); } #if !defined(NDEBUG) @@ -836,9 +835,10 @@ InstanceHandle_t DataWriterImpl::do_register_instance( assert(nullptr != payload); if (0 == payload->length || nullptr == payload->data) { - uint32_t size = fixed_payload_size_ ? fixed_payload_size_ : type_->getSerializedSizeProvider(key)(); + uint32_t size = fixed_payload_size_ ? fixed_payload_size_ : type_->calculate_serialized_size(key, + data_representation_); payload->reserve(size); - if (!type_->serialize(key, payload)) + if (!type_->serialize(key, *payload, data_representation_)) { EPROSIMA_LOG_WARNING(DATA_WRITER, "Key data serialization failed"); @@ -924,7 +924,7 @@ ReturnCode_t DataWriterImpl::get_key_value( return RETCODE_BAD_PARAMETER; } - if (!type_->m_isGetKeyDefined) + if (!type_->is_compute_key_provided) { EPROSIMA_LOG_ERROR(DATA_WRITER, "Topic is NO_KEY, operation not permitted"); return RETCODE_ILLEGAL_OPERATION; @@ -954,7 +954,7 @@ ReturnCode_t DataWriterImpl::get_key_value( return RETCODE_BAD_PARAMETER; } - type_->deserialize(payload, key_holder); + type_->deserialize(*payload, key_holder); return RETCODE_OK; } @@ -981,7 +981,7 @@ ReturnCode_t DataWriterImpl::check_new_change_preconditions( || change_kind == NOT_ALIVE_DISPOSED || change_kind == NOT_ALIVE_DISPOSED_UNREGISTERED) { - if (!type_->m_isGetKeyDefined) + if (!type_->is_compute_key_provided) { EPROSIMA_LOG_ERROR(DATA_WRITER, "Topic is NO_KEY, operation not permitted"); return RETCODE_ILLEGAL_OPERATION; @@ -1015,12 +1015,14 @@ ReturnCode_t DataWriterImpl::perform_create_new_change( bool was_loaned = check_and_remove_loan(data, payload); if (!was_loaned) { - if (!get_free_payload_from_pool(type_->getSerializedSizeProvider(data), payload)) + uint32_t payload_size = fixed_payload_size_ ? fixed_payload_size_ : type_->calculate_serialized_size( + data, data_representation_); + if (!get_free_payload_from_pool(payload_size, payload)) { return RETCODE_OUT_OF_RESOURCES; } - if ((ALIVE == change_kind) && !type_->serialize(data, &payload, data_representation_)) + if ((ALIVE == change_kind) && !type_->serialize(data, payload, data_representation_)) { EPROSIMA_LOG_WARNING(DATA_WRITER, "Data serialization returned false"); payload_pool_->release_payload(payload); @@ -1107,13 +1109,13 @@ ReturnCode_t DataWriterImpl::create_new_change_with_params( } InstanceHandle_t handle; - if (type_->m_isGetKeyDefined) + if (type_->is_compute_key_provided) { bool is_key_protected = false; #if HAVE_SECURITY is_key_protected = writer_->getAttributes().security_attributes().is_key_protected; #endif // if HAVE_SECURITY - type_->getKey(data, &handle, is_key_protected); + type_->compute_key(data, handle, is_key_protected); } return perform_create_new_change(changeKind, data, wparams, handle); @@ -1328,7 +1330,7 @@ void DataWriterImpl::InnerDataWriterListener::on_writer_change_received_by_all( RTPSWriter* /*writer*/, CacheChange_t* ch) { - if (data_writer_->type_->m_isGetKeyDefined && + if (data_writer_->type_->is_compute_key_provided && (NOT_ALIVE_UNREGISTERED == ch->kind || NOT_ALIVE_DISPOSED_UNREGISTERED == ch->kind)) { @@ -1684,7 +1686,7 @@ fastdds::TopicAttributes DataWriterImpl::get_topic_attributes( topic_att.resourceLimitsQos = qos.resource_limits(); topic_att.topicName = topic.get_name(); topic_att.topicDataType = topic.get_type_name(); - topic_att.topicKind = type->m_isGetKeyDefined ? WITH_KEY : NO_KEY; + topic_att.topicKind = type->is_compute_key_provided ? WITH_KEY : NO_KEY; if (type->auto_fill_type_information() && xtypes::TK_NONE != type->type_identifiers().type_identifier1()._d()) { if (RETCODE_OK == @@ -1862,7 +1864,7 @@ ReturnCode_t DataWriterImpl::check_qos_including_resource_limits( { ReturnCode_t check_qos_return = check_qos(qos); if (RETCODE_OK == check_qos_return && - type->m_isGetKeyDefined) + type->is_compute_key_provided) { check_qos_return = check_allocation_consistency(qos); } @@ -2116,6 +2118,23 @@ bool DataWriterImpl::release_payload_pool() return result; } +bool DataWriterImpl::get_free_payload_from_pool( + uint32_t size, + SerializedPayload_t& payload) +{ + if (!payload_pool_) + { + return false; + } + + if (!payload_pool_->get_payload(size, payload)) + { + return false; + } + + return true; +} + bool DataWriterImpl::add_loan( const void* const data, SerializedPayload_t& payload) @@ -2146,7 +2165,7 @@ ReturnCode_t DataWriterImpl::check_datasharing_compatible( qos_.endpoint().history_memory_policy == eprosima::fastdds::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE) && type_.is_bounded(); - bool has_key = type_->m_isGetKeyDefined; + bool has_key = type_->is_compute_key_provided; is_datasharing_compatible = false; switch (qos_.data_sharing().kind()) diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.hpp b/src/cpp/fastdds/publisher/DataWriterImpl.hpp index 7381286a291..3f0b301f07e 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.hpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.hpp @@ -662,24 +662,9 @@ class DataWriterImpl : protected rtps::IReaderDataFilter const fastdds::rtps::WriterAttributes& writer_attributes, bool& is_datasharing_compatible) const; - template bool get_free_payload_from_pool( - const SizeFunctor& size_getter, - SerializedPayload_t& payload) - { - if (!payload_pool_) - { - return false; - } - - uint32_t size = fixed_payload_size_ ? fixed_payload_size_ : size_getter(); - if (!payload_pool_->get_payload(size, payload)) - { - return false; - } - - return true; - } + uint32_t size, + SerializedPayload_t& payload); bool add_loan( const void* const data, diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index 4d0e5020aa6..70bbfc100f2 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -113,7 +113,7 @@ DataReaderImpl::DataReaderImpl( { EndpointAttributes endpoint_attributes; endpoint_attributes.endpointKind = READER; - endpoint_attributes.topicKind = type_->m_isGetKeyDefined ? WITH_KEY : NO_KEY; + endpoint_attributes.topicKind = type_->is_compute_key_provided ? WITH_KEY : NO_KEY; endpoint_attributes.setEntityID(qos_.endpoint().entity_id); endpoint_attributes.setUserDefinedID(qos_.endpoint().user_defined_id); RTPSParticipantImpl::preprocess_endpoint_attributes( @@ -166,7 +166,7 @@ ReturnCode_t DataReaderImpl::enable() att.endpoint.durabilityKind = qos_.durability().durabilityKind(); att.endpoint.endpointKind = READER; att.endpoint.reliabilityKind = qos_.reliability().kind == RELIABLE_RELIABILITY_QOS ? RELIABLE : BEST_EFFORT; - att.endpoint.topicKind = type_->m_isGetKeyDefined ? WITH_KEY : NO_KEY; + att.endpoint.topicKind = type_->is_compute_key_provided ? WITH_KEY : NO_KEY; att.endpoint.multicastLocatorList = qos_.endpoint().multicast_locator_list; att.endpoint.unicastLocatorList = qos_.endpoint().unicast_locator_list; att.endpoint.remoteLocatorList = qos_.endpoint().remote_locator_list; @@ -1489,7 +1489,7 @@ ReturnCode_t DataReaderImpl::check_qos_including_resource_limits( { ReturnCode_t check_qos_return = check_qos(qos); if (RETCODE_OK == check_qos_return && - type->m_isGetKeyDefined) + type->is_compute_key_provided) { check_qos_return = check_allocation_consistency(qos); } @@ -1773,7 +1773,7 @@ void DataReaderImpl::set_qos( fastdds::TopicAttributes DataReaderImpl::topic_attributes() const { fastdds::TopicAttributes topic_att; - topic_att.topicKind = type_->m_isGetKeyDefined ? WITH_KEY : NO_KEY; + topic_att.topicKind = type_->is_compute_key_provided ? WITH_KEY : NO_KEY; topic_att.topicName = topic_->get_impl()->get_rtps_topic_name(); topic_att.topicDataType = topic_->get_type_name(); topic_att.historyQos = qos_.history(); @@ -1874,7 +1874,7 @@ ReturnCode_t DataReaderImpl::check_datasharing_compatible( (void) reader_attributes; #endif // HAVE_SECURITY - bool has_key = type_->m_isGetKeyDefined; + bool has_key = type_->is_compute_key_provided; is_datasharing_compatible = false; switch (qos_.data_sharing().kind()) @@ -1985,9 +1985,9 @@ InstanceHandle_t DataReaderImpl::lookup_instance( { InstanceHandle_t handle = HANDLE_NIL; - if (instance && type_->m_isGetKeyDefined) + if (instance && type_->is_compute_key_provided) { - if (type_->getKey(const_cast(instance), &handle, false)) + if (type_->compute_key(const_cast(instance), handle, false)) { if (!history_.is_instance_present(handle)) { diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp index 3ce1d7be02f..92e36413daa 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp @@ -370,7 +370,7 @@ struct ReadTakeCommand if (data_values_.has_ownership()) { // perform deserialization - return type_->deserialize(payload, data_values_.buffer()[current_slot_]); + return type_->deserialize(*payload, data_values_.buffer()[current_slot_]); } else { diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl/SampleLoanManager.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl/SampleLoanManager.hpp index c77200b0db4..e728582f244 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl/SampleLoanManager.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl/SampleLoanManager.hpp @@ -64,7 +64,7 @@ struct SampleLoanManager OutstandingLoanItem item; if (!is_plain_) { - item.sample = type_->createData(); + item.sample = type_->create_data(); } free_loans_.push_back(std::move(item)); } @@ -76,7 +76,7 @@ struct SampleLoanManager { for (const OutstandingLoanItem& item : free_loans_) { - type_->deleteData(item.sample); + type_->delete_data(item.sample); } } } @@ -110,7 +110,7 @@ struct SampleLoanManager // Create sample if necessary if (!is_plain_) { - item->sample = type_->createData(); + item->sample = type_->create_data(); } } } @@ -140,7 +140,7 @@ struct SampleLoanManager } else { - type_->deserialize(&item->payload, item->sample); + type_->deserialize(item->payload, item->sample); } // Increment reference counter and return sample diff --git a/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp b/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp index c28801583ad..0dcd18a45dc 100644 --- a/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp +++ b/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp @@ -52,7 +52,7 @@ static HistoryAttributes to_history_attributes( auto max_samples = qos.resource_limits().max_samples; auto mempolicy = qos.endpoint().history_memory_policy; - auto payloadMaxSize = type->m_typeSize + 3; // possible alignment + auto payloadMaxSize = type->max_serialized_type_size + 3; // possible alignment return HistoryAttributes(mempolicy, payloadMaxSize, initial_samples, max_samples); } @@ -67,9 +67,8 @@ DataReaderHistory::DataReaderHistory( , resource_limited_qos_(qos.resource_limits()) , topic_name_(topic.get_name()) , type_name_(topic.get_type_name()) - , has_keys_(type->m_isGetKeyDefined) + , has_keys_(type->is_compute_key_provided) , type_(type.get()) - , get_key_object_(nullptr) { if (resource_limited_qos_.max_samples <= 0) { @@ -86,10 +85,8 @@ DataReaderHistory::DataReaderHistory( resource_limited_qos_.max_samples_per_instance = std::numeric_limits::max(); } - if (type_->m_isGetKeyDefined) + if (type_->is_compute_key_provided) { - get_key_object_ = type_->createData(); - if (resource_limited_qos_.max_samples_per_instance < std::numeric_limits::max()) { key_changes_allocation_.maximum = resource_limited_qos_.max_samples_per_instance; @@ -146,12 +143,12 @@ DataReaderHistory::DataReaderHistory( if (type_ != nullptr) { EPROSIMA_LOG_INFO(SUBSCRIBER, "Getting Key of change with no Key transmitted"); - type_->deserialize(&a_change->serializedPayload, get_key_object_); bool is_key_protected = false; #if HAVE_SECURITY is_key_protected = mp_reader->getAttributes().security_attributes().is_key_protected; #endif // if HAVE_SECURITY - return type_->getKey(get_key_object_, &a_change->instanceHandle, is_key_protected); + return type_->compute_key(a_change->serializedPayload, a_change->instanceHandle, + is_key_protected); } EPROSIMA_LOG_WARNING(SUBSCRIBER, "NO KEY in topic: " << topic_name_ @@ -163,10 +160,6 @@ DataReaderHistory::DataReaderHistory( DataReaderHistory::~DataReaderHistory() { - if (type_->m_isGetKeyDefined) - { - type_->deleteData(get_key_object_); - } } bool DataReaderHistory::can_change_be_added_nts( diff --git a/src/cpp/fastdds/subscriber/history/DataReaderHistory.hpp b/src/cpp/fastdds/subscriber/history/DataReaderHistory.hpp index b9dea5ba1a8..16182cb77eb 100644 --- a/src/cpp/fastdds/subscriber/history/DataReaderHistory.hpp +++ b/src/cpp/fastdds/subscriber/history/DataReaderHistory.hpp @@ -390,9 +390,6 @@ class DataReaderHistory : public eprosima::fastdds::rtps::ReaderHistory //!TopicDataType fastdds::dds::TopicDataType* type_; - //!Type object to deserialize Key - void* get_key_object_; - /// Function to compute the instance handle of a received change std::function compute_key_for_change_fn_; /// Function processing a received change diff --git a/src/cpp/fastdds/topic/TopicDataType.cpp b/src/cpp/fastdds/topic/TopicDataType.cpp deleted file mode 100644 index 53125b55a20..00000000000 --- a/src/cpp/fastdds/topic/TopicDataType.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file TopicDataType.cpp - */ - -#include -#include -#include - -#include - -#include -#include -#include -#include - -namespace eprosima { -namespace fastdds { -namespace dds { - -TopicDataType::TopicDataType() - : m_typeSize(0) - , m_isGetKeyDefined(false) - , auto_fill_type_information_(true) -{ -} - -TopicDataType::~TopicDataType() -{ -} - -bool TopicDataType::serialize( - const void* const data, - fastdds::rtps::SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - - static_cast(data_representation); - return serialize(data, payload); -} - -std::function TopicDataType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - static_cast(data); - static_cast(data_representation); - return []() - { - return 0; - }; -} - -} /* namespace dds */ -} /* namespace fastdds */ -} /* namespace eprosima */ diff --git a/src/cpp/fastdds/topic/TopicImpl.cpp b/src/cpp/fastdds/topic/TopicImpl.cpp index 0ffc3293c57..43bd741960e 100644 --- a/src/cpp/fastdds/topic/TopicImpl.cpp +++ b/src/cpp/fastdds/topic/TopicImpl.cpp @@ -56,7 +56,7 @@ ReturnCode_t TopicImpl::check_qos_including_resource_limits( { ReturnCode_t check_qos_return = check_qos(qos); if (RETCODE_OK == check_qos_return && - type->m_isGetKeyDefined) + type->is_compute_key_provided) { check_qos_return = check_allocation_consistency(qos); } diff --git a/src/cpp/fastdds/topic/TypeSupport.cpp b/src/cpp/fastdds/topic/TypeSupport.cpp index ce137c068b1..9553fea7002 100644 --- a/src/cpp/fastdds/topic/TypeSupport.cpp +++ b/src/cpp/fastdds/topic/TypeSupport.cpp @@ -45,7 +45,7 @@ ReturnCode_t TypeSupport::register_type( bool TypeSupport::serialize( const void* const data, - fastdds::rtps::SerializedPayload_t* payload, + fastdds::rtps::SerializedPayload_t& payload, DataRepresentationId_t data_representation) { bool result = false; @@ -62,7 +62,7 @@ bool TypeSupport::serialize( } bool TypeSupport::deserialize( - fastdds::rtps::SerializedPayload_t* payload, + fastdds::rtps::SerializedPayload_t& payload, void* data) { bool result = false; diff --git a/src/cpp/fastdds/xtypes/dynamic_types/DynamicPubSubType.cpp b/src/cpp/fastdds/xtypes/dynamic_types/DynamicPubSubType.cpp index fb64b11be5b..e2ec3ec6ac4 100644 --- a/src/cpp/fastdds/xtypes/dynamic_types/DynamicPubSubType.cpp +++ b/src/cpp/fastdds/xtypes/dynamic_types/DynamicPubSubType.cpp @@ -49,7 +49,7 @@ DynamicPubSubType::~DynamicPubSubType() } } -void* DynamicPubSubType::createData() +void* DynamicPubSubType::create_data() { if (!dynamic_type_) { @@ -66,7 +66,7 @@ void* DynamicPubSubType::createData() } } -void DynamicPubSubType::deleteData( +void DynamicPubSubType::delete_data( void* data) { traits::ref_type* data_ptr = static_cast::ref_type*>(data); @@ -75,18 +75,18 @@ void DynamicPubSubType::deleteData( } bool DynamicPubSubType::deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) { traits::ref_type* data_ptr = static_cast::ref_type*>(data); - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that manages the raw buffer. eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); // Object that deserializes the data. try { // Deserialize encapsulation. deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; deser >> *data_ptr; } @@ -102,12 +102,33 @@ traits::ref_type DynamicPubSubType::get_dynamic_type() const noexce return dynamic_type_; } -bool DynamicPubSubType::getKey( +bool DynamicPubSubType::compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& handle, + bool force_md5) +{ + if (!dynamic_type_ || !is_compute_key_provided) + { + return false; + } + + traits::ref_type temp_val {traits::narrow( + DynamicDataFactory::get_instance()->create_data( + dynamic_type_))}; + if (deserialize(payload, static_cast(&temp_val))) + { + return compute_key(static_cast(&temp_val), handle, force_md5); + } + + return false; +} + +bool DynamicPubSubType::compute_key( const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t* handle, + eprosima::fastdds::rtps::InstanceHandle_t& handle, bool force_md5) { - if (!dynamic_type_ || !m_isGetKeyDefined) + if (!dynamic_type_ || !is_compute_key_provided) { return false; } @@ -135,65 +156,56 @@ bool DynamicPubSubType::getKey( 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; } -std::function DynamicPubSubType::getSerializedSizeProvider( - const void* const data) -{ - return getSerializedSizeProvider(data, DEFAULT_DATA_REPRESENTATION); -} - -std::function DynamicPubSubType::getSerializedSizeProvider( +uint32_t DynamicPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { const traits::ref_type* data_ptr = static_cast::ref_type*>(data); - return [data_ptr, data_representation]() -> uint32_t - { - 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( - *data_ptr, current_alignment)) + 4u /*encapsulation*/; - - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - }; + 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( + *data_ptr, current_alignment)) + 4u /*encapsulation*/; + + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } } bool DynamicPubSubType::serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, fastdds::dds::DataRepresentationId_t data_representation) { const traits::ref_type* data_ptr = static_cast::ref_type*>(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + 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 == fastdds::dds::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; + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; auto type_impl = traits::narrow(dynamic_type_); ser.set_encoding_flag(get_fastcdr_encoding_flag(type_impl->get_descriptor().extensibility_kind(), @@ -213,7 +225,7 @@ bool DynamicPubSubType::serialize( return false; } - payload->length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length + payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length return true; } @@ -255,15 +267,15 @@ void DynamicPubSubType::register_type_object_representation() void DynamicPubSubType::update_dynamic_type() { - m_isGetKeyDefined = false; + is_compute_key_provided = false; if (nullptr == dynamic_type_) { return; } - m_typeSize = static_cast(DynamicDataImpl::calculate_max_serialized_size(dynamic_type_) + 4); - setName(dynamic_type_->get_name()); + max_serialized_type_size = static_cast(DynamicDataImpl::calculate_max_serialized_size(dynamic_type_) + 4); + set_name(dynamic_type_->get_name().to_string()); if (TK_STRUCTURE == dynamic_type_->get_kind()) { @@ -273,7 +285,7 @@ void DynamicPubSubType::update_dynamic_type() auto member_impl = traits::narrow(member); if (member_impl->get_descriptor().is_key()) { - m_isGetKeyDefined = true; + is_compute_key_provided = true; break; } } diff --git a/src/cpp/fastdds/xtypes/type_representation/dds_xtypes_typeobjectPubSubTypes.cxx b/src/cpp/fastdds/xtypes/type_representation/dds_xtypes_typeobjectPubSubTypes.cxx index 5fd99342f29..e00f7711ff0 100644 --- a/src/cpp/fastdds/xtypes/type_representation/dds_xtypes_typeobjectPubSubTypes.cxx +++ b/src/cpp/fastdds/xtypes/type_representation/dds_xtypes_typeobjectPubSubTypes.cxx @@ -41,49 +41,42 @@ namespace xtypes { StringSTypeDefnPubSubType::StringSTypeDefnPubSubType() { - setName("eprosima::fastdds::dds::xtypes::StringSTypeDefn"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StringSTypeDefn::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_StringSTypeDefn_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::StringSTypeDefn"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_StringSTypeDefn_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_StringSTypeDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_StringSTypeDefn_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_StringSTypeDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_StringSTypeDefn_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StringSTypeDefnPubSubType::~StringSTypeDefnPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StringSTypeDefnPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StringSTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -98,16 +91,12 @@ bool StringSTypeDefnPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StringSTypeDefnPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -116,18 +105,14 @@ bool StringSTypeDefnPubSubType::deserialize( StringSTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -140,52 +125,62 @@ bool StringSTypeDefnPubSubType::deserialize( return true; } -std::function StringSTypeDefnPubSubType::getSerializedSizeProvider( +uint32_t StringSTypeDefnPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StringSTypeDefnPubSubType::createData() + 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* StringSTypeDefnPubSubType::create_data() { return reinterpret_cast(new StringSTypeDefn()); } -void StringSTypeDefnPubSubType::deleteData( +void StringSTypeDefnPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StringSTypeDefnPubSubType::getKey( +bool StringSTypeDefnPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StringSTypeDefn data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StringSTypeDefnPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -193,35 +188,27 @@ bool StringSTypeDefnPubSubType::getKey( const StringSTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_StringSTypeDefn_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_StringSTypeDefn_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -235,49 +222,42 @@ void StringSTypeDefnPubSubType::register_type_object_representation() StringLTypeDefnPubSubType::StringLTypeDefnPubSubType() { - setName("eprosima::fastdds::dds::xtypes::StringLTypeDefn"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StringLTypeDefn::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_StringLTypeDefn_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::StringLTypeDefn"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_StringLTypeDefn_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_StringLTypeDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_StringLTypeDefn_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_StringLTypeDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_StringLTypeDefn_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StringLTypeDefnPubSubType::~StringLTypeDefnPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StringLTypeDefnPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StringLTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -292,16 +272,12 @@ bool StringLTypeDefnPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StringLTypeDefnPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -310,18 +286,14 @@ bool StringLTypeDefnPubSubType::deserialize( StringLTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -334,52 +306,62 @@ bool StringLTypeDefnPubSubType::deserialize( return true; } -std::function StringLTypeDefnPubSubType::getSerializedSizeProvider( +uint32_t StringLTypeDefnPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StringLTypeDefnPubSubType::createData() + 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* StringLTypeDefnPubSubType::create_data() { return reinterpret_cast(new StringLTypeDefn()); } -void StringLTypeDefnPubSubType::deleteData( +void StringLTypeDefnPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StringLTypeDefnPubSubType::getKey( +bool StringLTypeDefnPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StringLTypeDefn data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StringLTypeDefnPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -387,35 +369,27 @@ bool StringLTypeDefnPubSubType::getKey( const StringLTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_StringLTypeDefn_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_StringLTypeDefn_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -429,49 +403,42 @@ void StringLTypeDefnPubSubType::register_type_object_representation() PlainCollectionHeaderPubSubType::PlainCollectionHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::PlainCollectionHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(PlainCollectionHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_PlainCollectionHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::PlainCollectionHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_PlainCollectionHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_PlainCollectionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainCollectionHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_PlainCollectionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainCollectionHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PlainCollectionHeaderPubSubType::~PlainCollectionHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PlainCollectionHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PlainCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -486,16 +453,12 @@ bool PlainCollectionHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PlainCollectionHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -504,18 +467,14 @@ bool PlainCollectionHeaderPubSubType::deserialize( PlainCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -528,52 +487,62 @@ bool PlainCollectionHeaderPubSubType::deserialize( return true; } -std::function PlainCollectionHeaderPubSubType::getSerializedSizeProvider( +uint32_t PlainCollectionHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* PlainCollectionHeaderPubSubType::createData() + 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* PlainCollectionHeaderPubSubType::create_data() { return reinterpret_cast(new PlainCollectionHeader()); } -void PlainCollectionHeaderPubSubType::deleteData( +void PlainCollectionHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool PlainCollectionHeaderPubSubType::getKey( +bool PlainCollectionHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + PlainCollectionHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool PlainCollectionHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -581,35 +550,27 @@ bool PlainCollectionHeaderPubSubType::getKey( const PlainCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_PlainCollectionHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_PlainCollectionHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -623,49 +584,42 @@ void PlainCollectionHeaderPubSubType::register_type_object_representation() PlainSequenceSElemDefnPubSubType::PlainSequenceSElemDefnPubSubType() { - setName("eprosima::fastdds::dds::xtypes::PlainSequenceSElemDefn"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(PlainSequenceSElemDefn::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_PlainSequenceSElemDefn_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::PlainSequenceSElemDefn"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_PlainSequenceSElemDefn_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_PlainSequenceSElemDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainSequenceSElemDefn_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_PlainSequenceSElemDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainSequenceSElemDefn_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PlainSequenceSElemDefnPubSubType::~PlainSequenceSElemDefnPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PlainSequenceSElemDefnPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PlainSequenceSElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -680,16 +634,12 @@ bool PlainSequenceSElemDefnPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PlainSequenceSElemDefnPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -698,18 +648,14 @@ bool PlainSequenceSElemDefnPubSubType::deserialize( PlainSequenceSElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -722,52 +668,62 @@ bool PlainSequenceSElemDefnPubSubType::deserialize( return true; } -std::function PlainSequenceSElemDefnPubSubType::getSerializedSizeProvider( +uint32_t PlainSequenceSElemDefnPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* PlainSequenceSElemDefnPubSubType::createData() + 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* PlainSequenceSElemDefnPubSubType::create_data() { return reinterpret_cast(new PlainSequenceSElemDefn()); } -void PlainSequenceSElemDefnPubSubType::deleteData( +void PlainSequenceSElemDefnPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool PlainSequenceSElemDefnPubSubType::getKey( +bool PlainSequenceSElemDefnPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + PlainSequenceSElemDefn data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool PlainSequenceSElemDefnPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -775,35 +731,27 @@ bool PlainSequenceSElemDefnPubSubType::getKey( const PlainSequenceSElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_PlainSequenceSElemDefn_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_PlainSequenceSElemDefn_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -817,49 +765,42 @@ void PlainSequenceSElemDefnPubSubType::register_type_object_representation() PlainSequenceLElemDefnPubSubType::PlainSequenceLElemDefnPubSubType() { - setName("eprosima::fastdds::dds::xtypes::PlainSequenceLElemDefn"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(PlainSequenceLElemDefn::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_PlainSequenceLElemDefn_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::PlainSequenceLElemDefn"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_PlainSequenceLElemDefn_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_PlainSequenceLElemDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainSequenceLElemDefn_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_PlainSequenceLElemDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainSequenceLElemDefn_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PlainSequenceLElemDefnPubSubType::~PlainSequenceLElemDefnPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PlainSequenceLElemDefnPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PlainSequenceLElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -874,16 +815,12 @@ bool PlainSequenceLElemDefnPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PlainSequenceLElemDefnPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -892,18 +829,14 @@ bool PlainSequenceLElemDefnPubSubType::deserialize( PlainSequenceLElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -916,52 +849,62 @@ bool PlainSequenceLElemDefnPubSubType::deserialize( return true; } -std::function PlainSequenceLElemDefnPubSubType::getSerializedSizeProvider( +uint32_t PlainSequenceLElemDefnPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* PlainSequenceLElemDefnPubSubType::createData() + 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* PlainSequenceLElemDefnPubSubType::create_data() { return reinterpret_cast(new PlainSequenceLElemDefn()); } -void PlainSequenceLElemDefnPubSubType::deleteData( +void PlainSequenceLElemDefnPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool PlainSequenceLElemDefnPubSubType::getKey( +bool PlainSequenceLElemDefnPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + PlainSequenceLElemDefn data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool PlainSequenceLElemDefnPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -969,35 +912,27 @@ bool PlainSequenceLElemDefnPubSubType::getKey( const PlainSequenceLElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_PlainSequenceLElemDefn_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_PlainSequenceLElemDefn_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1011,49 +946,42 @@ void PlainSequenceLElemDefnPubSubType::register_type_object_representation() PlainArraySElemDefnPubSubType::PlainArraySElemDefnPubSubType() { - setName("eprosima::fastdds::dds::xtypes::PlainArraySElemDefn"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(PlainArraySElemDefn::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_PlainArraySElemDefn_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::PlainArraySElemDefn"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_PlainArraySElemDefn_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_PlainArraySElemDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainArraySElemDefn_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_PlainArraySElemDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainArraySElemDefn_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PlainArraySElemDefnPubSubType::~PlainArraySElemDefnPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PlainArraySElemDefnPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PlainArraySElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1068,16 +996,12 @@ bool PlainArraySElemDefnPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PlainArraySElemDefnPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1086,18 +1010,14 @@ bool PlainArraySElemDefnPubSubType::deserialize( PlainArraySElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1110,52 +1030,62 @@ bool PlainArraySElemDefnPubSubType::deserialize( return true; } -std::function PlainArraySElemDefnPubSubType::getSerializedSizeProvider( +uint32_t PlainArraySElemDefnPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* PlainArraySElemDefnPubSubType::createData() + 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* PlainArraySElemDefnPubSubType::create_data() { return reinterpret_cast(new PlainArraySElemDefn()); } -void PlainArraySElemDefnPubSubType::deleteData( +void PlainArraySElemDefnPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool PlainArraySElemDefnPubSubType::getKey( +bool PlainArraySElemDefnPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + PlainArraySElemDefn data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool PlainArraySElemDefnPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1163,35 +1093,27 @@ bool PlainArraySElemDefnPubSubType::getKey( const PlainArraySElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_PlainArraySElemDefn_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_PlainArraySElemDefn_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1205,49 +1127,42 @@ void PlainArraySElemDefnPubSubType::register_type_object_representation() PlainArrayLElemDefnPubSubType::PlainArrayLElemDefnPubSubType() { - setName("eprosima::fastdds::dds::xtypes::PlainArrayLElemDefn"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(PlainArrayLElemDefn::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_PlainArrayLElemDefn_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::PlainArrayLElemDefn"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_PlainArrayLElemDefn_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_PlainArrayLElemDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainArrayLElemDefn_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_PlainArrayLElemDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainArrayLElemDefn_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PlainArrayLElemDefnPubSubType::~PlainArrayLElemDefnPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PlainArrayLElemDefnPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PlainArrayLElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1262,16 +1177,12 @@ bool PlainArrayLElemDefnPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PlainArrayLElemDefnPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1280,18 +1191,14 @@ bool PlainArrayLElemDefnPubSubType::deserialize( PlainArrayLElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1304,52 +1211,62 @@ bool PlainArrayLElemDefnPubSubType::deserialize( return true; } -std::function PlainArrayLElemDefnPubSubType::getSerializedSizeProvider( +uint32_t PlainArrayLElemDefnPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* PlainArrayLElemDefnPubSubType::createData() + 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* PlainArrayLElemDefnPubSubType::create_data() { return reinterpret_cast(new PlainArrayLElemDefn()); } -void PlainArrayLElemDefnPubSubType::deleteData( +void PlainArrayLElemDefnPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool PlainArrayLElemDefnPubSubType::getKey( +bool PlainArrayLElemDefnPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + PlainArrayLElemDefn data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool PlainArrayLElemDefnPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1357,35 +1274,27 @@ bool PlainArrayLElemDefnPubSubType::getKey( const PlainArrayLElemDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_PlainArrayLElemDefn_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_PlainArrayLElemDefn_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1399,49 +1308,42 @@ void PlainArrayLElemDefnPubSubType::register_type_object_representation() PlainMapSTypeDefnPubSubType::PlainMapSTypeDefnPubSubType() { - setName("eprosima::fastdds::dds::xtypes::PlainMapSTypeDefn"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(PlainMapSTypeDefn::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_PlainMapSTypeDefn_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::PlainMapSTypeDefn"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_PlainMapSTypeDefn_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_PlainMapSTypeDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainMapSTypeDefn_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_PlainMapSTypeDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainMapSTypeDefn_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PlainMapSTypeDefnPubSubType::~PlainMapSTypeDefnPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PlainMapSTypeDefnPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PlainMapSTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1456,16 +1358,12 @@ bool PlainMapSTypeDefnPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PlainMapSTypeDefnPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1474,18 +1372,14 @@ bool PlainMapSTypeDefnPubSubType::deserialize( PlainMapSTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1498,52 +1392,62 @@ bool PlainMapSTypeDefnPubSubType::deserialize( return true; } -std::function PlainMapSTypeDefnPubSubType::getSerializedSizeProvider( +uint32_t PlainMapSTypeDefnPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* PlainMapSTypeDefnPubSubType::createData() + 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* PlainMapSTypeDefnPubSubType::create_data() { return reinterpret_cast(new PlainMapSTypeDefn()); } -void PlainMapSTypeDefnPubSubType::deleteData( +void PlainMapSTypeDefnPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool PlainMapSTypeDefnPubSubType::getKey( +bool PlainMapSTypeDefnPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + PlainMapSTypeDefn data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool PlainMapSTypeDefnPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1551,35 +1455,27 @@ bool PlainMapSTypeDefnPubSubType::getKey( const PlainMapSTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_PlainMapSTypeDefn_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_PlainMapSTypeDefn_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1593,49 +1489,42 @@ void PlainMapSTypeDefnPubSubType::register_type_object_representation() PlainMapLTypeDefnPubSubType::PlainMapLTypeDefnPubSubType() { - setName("eprosima::fastdds::dds::xtypes::PlainMapLTypeDefn"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(PlainMapLTypeDefn::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_PlainMapLTypeDefn_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::PlainMapLTypeDefn"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_PlainMapLTypeDefn_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_PlainMapLTypeDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainMapLTypeDefn_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_PlainMapLTypeDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_PlainMapLTypeDefn_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PlainMapLTypeDefnPubSubType::~PlainMapLTypeDefnPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PlainMapLTypeDefnPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PlainMapLTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1650,16 +1539,12 @@ bool PlainMapLTypeDefnPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PlainMapLTypeDefnPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1668,18 +1553,14 @@ bool PlainMapLTypeDefnPubSubType::deserialize( PlainMapLTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1692,52 +1573,62 @@ bool PlainMapLTypeDefnPubSubType::deserialize( return true; } -std::function PlainMapLTypeDefnPubSubType::getSerializedSizeProvider( +uint32_t PlainMapLTypeDefnPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* PlainMapLTypeDefnPubSubType::createData() + 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* PlainMapLTypeDefnPubSubType::create_data() { return reinterpret_cast(new PlainMapLTypeDefn()); } -void PlainMapLTypeDefnPubSubType::deleteData( +void PlainMapLTypeDefnPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool PlainMapLTypeDefnPubSubType::getKey( +bool PlainMapLTypeDefnPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + PlainMapLTypeDefn data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool PlainMapLTypeDefnPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1745,35 +1636,27 @@ bool PlainMapLTypeDefnPubSubType::getKey( const PlainMapLTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_PlainMapLTypeDefn_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_PlainMapLTypeDefn_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1787,49 +1670,42 @@ void PlainMapLTypeDefnPubSubType::register_type_object_representation() StronglyConnectedComponentIdPubSubType::StronglyConnectedComponentIdPubSubType() { - setName("eprosima::fastdds::dds::xtypes::StronglyConnectedComponentId"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StronglyConnectedComponentId::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_StronglyConnectedComponentId_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::StronglyConnectedComponentId"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_StronglyConnectedComponentId_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_StronglyConnectedComponentId_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_StronglyConnectedComponentId_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_StronglyConnectedComponentId_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_StronglyConnectedComponentId_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StronglyConnectedComponentIdPubSubType::~StronglyConnectedComponentIdPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StronglyConnectedComponentIdPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StronglyConnectedComponentId* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1844,16 +1720,12 @@ bool StronglyConnectedComponentIdPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StronglyConnectedComponentIdPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1862,18 +1734,14 @@ bool StronglyConnectedComponentIdPubSubType::deserialize( StronglyConnectedComponentId* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1886,52 +1754,62 @@ bool StronglyConnectedComponentIdPubSubType::deserialize( return true; } -std::function StronglyConnectedComponentIdPubSubType::getSerializedSizeProvider( +uint32_t StronglyConnectedComponentIdPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StronglyConnectedComponentIdPubSubType::createData() + 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* StronglyConnectedComponentIdPubSubType::create_data() { return reinterpret_cast(new StronglyConnectedComponentId()); } -void StronglyConnectedComponentIdPubSubType::deleteData( +void StronglyConnectedComponentIdPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StronglyConnectedComponentIdPubSubType::getKey( +bool StronglyConnectedComponentIdPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StronglyConnectedComponentId data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StronglyConnectedComponentIdPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1939,35 +1817,27 @@ bool StronglyConnectedComponentIdPubSubType::getKey( const StronglyConnectedComponentId* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_StronglyConnectedComponentId_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_StronglyConnectedComponentId_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1981,49 +1851,42 @@ void StronglyConnectedComponentIdPubSubType::register_type_object_representation ExtendedTypeDefnPubSubType::ExtendedTypeDefnPubSubType() { - setName("eprosima::fastdds::dds::xtypes::ExtendedTypeDefn"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ExtendedTypeDefn::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_ExtendedTypeDefn_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::ExtendedTypeDefn"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_ExtendedTypeDefn_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_ExtendedTypeDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_ExtendedTypeDefn_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_ExtendedTypeDefn_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_ExtendedTypeDefn_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ExtendedTypeDefnPubSubType::~ExtendedTypeDefnPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ExtendedTypeDefnPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ExtendedTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2038,16 +1901,12 @@ bool ExtendedTypeDefnPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ExtendedTypeDefnPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2056,18 +1915,14 @@ bool ExtendedTypeDefnPubSubType::deserialize( ExtendedTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2080,52 +1935,62 @@ bool ExtendedTypeDefnPubSubType::deserialize( return true; } -std::function ExtendedTypeDefnPubSubType::getSerializedSizeProvider( +uint32_t ExtendedTypeDefnPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ExtendedTypeDefnPubSubType::createData() + 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* ExtendedTypeDefnPubSubType::create_data() { return reinterpret_cast(new ExtendedTypeDefn()); } -void ExtendedTypeDefnPubSubType::deleteData( +void ExtendedTypeDefnPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ExtendedTypeDefnPubSubType::getKey( +bool ExtendedTypeDefnPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ExtendedTypeDefn data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ExtendedTypeDefnPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2133,35 +1998,27 @@ bool ExtendedTypeDefnPubSubType::getKey( const ExtendedTypeDefn* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_ExtendedTypeDefn_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_ExtendedTypeDefn_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2175,49 +2032,42 @@ void ExtendedTypeDefnPubSubType::register_type_object_representation() DummyPubSubType::DummyPubSubType() { - setName("eprosima::fastdds::dds::xtypes::Dummy"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Dummy::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_Dummy_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::Dummy"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_Dummy_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_Dummy_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_Dummy_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_Dummy_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_Dummy_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DummyPubSubType::~DummyPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DummyPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Dummy* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2232,16 +2082,12 @@ bool DummyPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DummyPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2250,18 +2096,14 @@ bool DummyPubSubType::deserialize( Dummy* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2274,52 +2116,62 @@ bool DummyPubSubType::deserialize( return true; } -std::function DummyPubSubType::getSerializedSizeProvider( +uint32_t DummyPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DummyPubSubType::createData() + 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* DummyPubSubType::create_data() { return reinterpret_cast(new Dummy()); } -void DummyPubSubType::deleteData( +void DummyPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool DummyPubSubType::getKey( +bool DummyPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Dummy data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool DummyPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2327,35 +2179,27 @@ bool DummyPubSubType::getKey( const Dummy* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_Dummy_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_Dummy_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2374,49 +2218,42 @@ void DummyPubSubType::register_type_object_representation() ExtendedAnnotationParameterValuePubSubType::ExtendedAnnotationParameterValuePubSubType() { - setName("eprosima::fastdds::dds::xtypes::ExtendedAnnotationParameterValue"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ExtendedAnnotationParameterValue::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_ExtendedAnnotationParameterValue_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::ExtendedAnnotationParameterValue"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_ExtendedAnnotationParameterValue_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_ExtendedAnnotationParameterValue_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_ExtendedAnnotationParameterValue_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_ExtendedAnnotationParameterValue_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_ExtendedAnnotationParameterValue_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ExtendedAnnotationParameterValuePubSubType::~ExtendedAnnotationParameterValuePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ExtendedAnnotationParameterValuePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ExtendedAnnotationParameterValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2431,16 +2268,12 @@ bool ExtendedAnnotationParameterValuePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ExtendedAnnotationParameterValuePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2449,18 +2282,14 @@ bool ExtendedAnnotationParameterValuePubSubType::deserialize( ExtendedAnnotationParameterValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2473,88 +2302,90 @@ bool ExtendedAnnotationParameterValuePubSubType::deserialize( return true; } -std::function ExtendedAnnotationParameterValuePubSubType::getSerializedSizeProvider( +uint32_t ExtendedAnnotationParameterValuePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ExtendedAnnotationParameterValuePubSubType::createData() + 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* ExtendedAnnotationParameterValuePubSubType::create_data() { return reinterpret_cast(new ExtendedAnnotationParameterValue()); } -void ExtendedAnnotationParameterValuePubSubType::deleteData( +void ExtendedAnnotationParameterValuePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ExtendedAnnotationParameterValuePubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, +bool ExtendedAnnotationParameterValuePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const ExtendedAnnotationParameterValue* p_type = static_cast(data); + ExtendedAnnotationParameterValue data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - eprosima_fastdds_dds_xtypes_ExtendedAnnotationParameterValue_max_key_cdr_typesize); + return false; +} + +bool ExtendedAnnotationParameterValuePubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const ExtendedAnnotationParameterValue* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + eprosima_fastdds_dds_xtypes_ExtendedAnnotationParameterValue_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_ExtendedAnnotationParameterValue_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2569,49 +2400,42 @@ void ExtendedAnnotationParameterValuePubSubType::register_type_object_representa AppliedAnnotationParameterPubSubType::AppliedAnnotationParameterPubSubType() { - setName("eprosima::fastdds::dds::xtypes::AppliedAnnotationParameter"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppliedAnnotationParameter::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_AppliedAnnotationParameter_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::AppliedAnnotationParameter"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_AppliedAnnotationParameter_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_AppliedAnnotationParameter_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_AppliedAnnotationParameter_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_AppliedAnnotationParameter_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_AppliedAnnotationParameter_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppliedAnnotationParameterPubSubType::~AppliedAnnotationParameterPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppliedAnnotationParameterPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppliedAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2626,16 +2450,12 @@ bool AppliedAnnotationParameterPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppliedAnnotationParameterPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2644,18 +2464,14 @@ bool AppliedAnnotationParameterPubSubType::deserialize( AppliedAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2668,52 +2484,62 @@ bool AppliedAnnotationParameterPubSubType::deserialize( return true; } -std::function AppliedAnnotationParameterPubSubType::getSerializedSizeProvider( +uint32_t AppliedAnnotationParameterPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppliedAnnotationParameterPubSubType::createData() + 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* AppliedAnnotationParameterPubSubType::create_data() { return reinterpret_cast(new AppliedAnnotationParameter()); } -void AppliedAnnotationParameterPubSubType::deleteData( +void AppliedAnnotationParameterPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppliedAnnotationParameterPubSubType::getKey( +bool AppliedAnnotationParameterPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppliedAnnotationParameter data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppliedAnnotationParameterPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2721,35 +2547,27 @@ bool AppliedAnnotationParameterPubSubType::getKey( const AppliedAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_AppliedAnnotationParameter_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_AppliedAnnotationParameter_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2764,49 +2582,42 @@ void AppliedAnnotationParameterPubSubType::register_type_object_representation() AppliedAnnotationPubSubType::AppliedAnnotationPubSubType() { - setName("eprosima::fastdds::dds::xtypes::AppliedAnnotation"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppliedAnnotation::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_AppliedAnnotation_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::AppliedAnnotation"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_AppliedAnnotation_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_AppliedAnnotation_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_AppliedAnnotation_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_AppliedAnnotation_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_AppliedAnnotation_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppliedAnnotationPubSubType::~AppliedAnnotationPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppliedAnnotationPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppliedAnnotation* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2821,16 +2632,12 @@ bool AppliedAnnotationPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppliedAnnotationPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2839,18 +2646,14 @@ bool AppliedAnnotationPubSubType::deserialize( AppliedAnnotation* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2863,52 +2666,62 @@ bool AppliedAnnotationPubSubType::deserialize( return true; } -std::function AppliedAnnotationPubSubType::getSerializedSizeProvider( +uint32_t AppliedAnnotationPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppliedAnnotationPubSubType::createData() + 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* AppliedAnnotationPubSubType::create_data() { return reinterpret_cast(new AppliedAnnotation()); } -void AppliedAnnotationPubSubType::deleteData( +void AppliedAnnotationPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppliedAnnotationPubSubType::getKey( +bool AppliedAnnotationPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppliedAnnotation data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppliedAnnotationPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2916,35 +2729,27 @@ bool AppliedAnnotationPubSubType::getKey( const AppliedAnnotation* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_AppliedAnnotation_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_AppliedAnnotation_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2959,49 +2764,42 @@ void AppliedAnnotationPubSubType::register_type_object_representation() AppliedVerbatimAnnotationPubSubType::AppliedVerbatimAnnotationPubSubType() { - setName("eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppliedVerbatimAnnotation::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_AppliedVerbatimAnnotation_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_AppliedVerbatimAnnotation_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_AppliedVerbatimAnnotation_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_AppliedVerbatimAnnotation_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_AppliedVerbatimAnnotation_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_AppliedVerbatimAnnotation_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppliedVerbatimAnnotationPubSubType::~AppliedVerbatimAnnotationPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppliedVerbatimAnnotationPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppliedVerbatimAnnotation* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3016,16 +2814,12 @@ bool AppliedVerbatimAnnotationPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppliedVerbatimAnnotationPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3034,18 +2828,14 @@ bool AppliedVerbatimAnnotationPubSubType::deserialize( AppliedVerbatimAnnotation* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3058,52 +2848,62 @@ bool AppliedVerbatimAnnotationPubSubType::deserialize( return true; } -std::function AppliedVerbatimAnnotationPubSubType::getSerializedSizeProvider( +uint32_t AppliedVerbatimAnnotationPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppliedVerbatimAnnotationPubSubType::createData() + 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* AppliedVerbatimAnnotationPubSubType::create_data() { return reinterpret_cast(new AppliedVerbatimAnnotation()); } -void AppliedVerbatimAnnotationPubSubType::deleteData( +void AppliedVerbatimAnnotationPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppliedVerbatimAnnotationPubSubType::getKey( +bool AppliedVerbatimAnnotationPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppliedVerbatimAnnotation data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppliedVerbatimAnnotationPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3111,35 +2911,27 @@ bool AppliedVerbatimAnnotationPubSubType::getKey( const AppliedVerbatimAnnotation* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_AppliedVerbatimAnnotation_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_AppliedVerbatimAnnotation_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3153,49 +2945,42 @@ void AppliedVerbatimAnnotationPubSubType::register_type_object_representation() AppliedBuiltinMemberAnnotationsPubSubType::AppliedBuiltinMemberAnnotationsPubSubType() { - setName("eprosima::fastdds::dds::xtypes::AppliedBuiltinMemberAnnotations"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppliedBuiltinMemberAnnotations::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_AppliedBuiltinMemberAnnotations_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::AppliedBuiltinMemberAnnotations"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_AppliedBuiltinMemberAnnotations_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_AppliedBuiltinMemberAnnotations_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_AppliedBuiltinMemberAnnotations_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_AppliedBuiltinMemberAnnotations_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_AppliedBuiltinMemberAnnotations_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppliedBuiltinMemberAnnotationsPubSubType::~AppliedBuiltinMemberAnnotationsPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppliedBuiltinMemberAnnotationsPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppliedBuiltinMemberAnnotations* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3210,16 +2995,12 @@ bool AppliedBuiltinMemberAnnotationsPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppliedBuiltinMemberAnnotationsPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3228,18 +3009,14 @@ bool AppliedBuiltinMemberAnnotationsPubSubType::deserialize( AppliedBuiltinMemberAnnotations* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3252,52 +3029,62 @@ bool AppliedBuiltinMemberAnnotationsPubSubType::deserialize( return true; } -std::function AppliedBuiltinMemberAnnotationsPubSubType::getSerializedSizeProvider( +uint32_t AppliedBuiltinMemberAnnotationsPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppliedBuiltinMemberAnnotationsPubSubType::createData() + 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* AppliedBuiltinMemberAnnotationsPubSubType::create_data() { return reinterpret_cast(new AppliedBuiltinMemberAnnotations()); } -void AppliedBuiltinMemberAnnotationsPubSubType::deleteData( +void AppliedBuiltinMemberAnnotationsPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppliedBuiltinMemberAnnotationsPubSubType::getKey( +bool AppliedBuiltinMemberAnnotationsPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppliedBuiltinMemberAnnotations data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppliedBuiltinMemberAnnotationsPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3305,35 +3092,27 @@ bool AppliedBuiltinMemberAnnotationsPubSubType::getKey( const AppliedBuiltinMemberAnnotations* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_AppliedBuiltinMemberAnnotations_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_AppliedBuiltinMemberAnnotations_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3347,49 +3126,42 @@ void AppliedBuiltinMemberAnnotationsPubSubType::register_type_object_representat CommonStructMemberPubSubType::CommonStructMemberPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonStructMember"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonStructMember::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonStructMember_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonStructMember"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonStructMember_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonStructMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonStructMember_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonStructMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonStructMember_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonStructMemberPubSubType::~CommonStructMemberPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonStructMemberPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonStructMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3404,16 +3176,12 @@ bool CommonStructMemberPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonStructMemberPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3422,18 +3190,14 @@ bool CommonStructMemberPubSubType::deserialize( CommonStructMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3446,52 +3210,62 @@ bool CommonStructMemberPubSubType::deserialize( return true; } -std::function CommonStructMemberPubSubType::getSerializedSizeProvider( +uint32_t CommonStructMemberPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonStructMemberPubSubType::createData() + 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* CommonStructMemberPubSubType::create_data() { return reinterpret_cast(new CommonStructMember()); } -void CommonStructMemberPubSubType::deleteData( +void CommonStructMemberPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonStructMemberPubSubType::getKey( +bool CommonStructMemberPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonStructMember data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonStructMemberPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3499,35 +3273,27 @@ bool CommonStructMemberPubSubType::getKey( const CommonStructMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonStructMember_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonStructMember_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3541,49 +3307,42 @@ void CommonStructMemberPubSubType::register_type_object_representation() CompleteMemberDetailPubSubType::CompleteMemberDetailPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteMemberDetail"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteMemberDetail::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteMemberDetail_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteMemberDetail"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteMemberDetail_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteMemberDetail_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteMemberDetail_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteMemberDetail_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteMemberDetail_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteMemberDetailPubSubType::~CompleteMemberDetailPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteMemberDetailPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteMemberDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3598,16 +3357,12 @@ bool CompleteMemberDetailPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteMemberDetailPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3616,18 +3371,14 @@ bool CompleteMemberDetailPubSubType::deserialize( CompleteMemberDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3640,52 +3391,62 @@ bool CompleteMemberDetailPubSubType::deserialize( return true; } -std::function CompleteMemberDetailPubSubType::getSerializedSizeProvider( +uint32_t CompleteMemberDetailPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteMemberDetailPubSubType::createData() + 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* CompleteMemberDetailPubSubType::create_data() { return reinterpret_cast(new CompleteMemberDetail()); } -void CompleteMemberDetailPubSubType::deleteData( +void CompleteMemberDetailPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteMemberDetailPubSubType::getKey( +bool CompleteMemberDetailPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteMemberDetail data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteMemberDetailPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3693,35 +3454,27 @@ bool CompleteMemberDetailPubSubType::getKey( const CompleteMemberDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteMemberDetail_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteMemberDetail_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3735,49 +3488,42 @@ void CompleteMemberDetailPubSubType::register_type_object_representation() MinimalMemberDetailPubSubType::MinimalMemberDetailPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalMemberDetail"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalMemberDetail::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalMemberDetail_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalMemberDetail"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalMemberDetail_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalMemberDetail_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalMemberDetail_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalMemberDetail_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalMemberDetail_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalMemberDetailPubSubType::~MinimalMemberDetailPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalMemberDetailPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalMemberDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3792,16 +3538,12 @@ bool MinimalMemberDetailPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalMemberDetailPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3810,18 +3552,14 @@ bool MinimalMemberDetailPubSubType::deserialize( MinimalMemberDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3834,52 +3572,62 @@ bool MinimalMemberDetailPubSubType::deserialize( return true; } -std::function MinimalMemberDetailPubSubType::getSerializedSizeProvider( +uint32_t MinimalMemberDetailPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalMemberDetailPubSubType::createData() + 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* MinimalMemberDetailPubSubType::create_data() { return reinterpret_cast(new MinimalMemberDetail()); } -void MinimalMemberDetailPubSubType::deleteData( +void MinimalMemberDetailPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalMemberDetailPubSubType::getKey( +bool MinimalMemberDetailPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalMemberDetail data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalMemberDetailPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3887,35 +3635,27 @@ bool MinimalMemberDetailPubSubType::getKey( const MinimalMemberDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalMemberDetail_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalMemberDetail_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3929,49 +3669,42 @@ void MinimalMemberDetailPubSubType::register_type_object_representation() CompleteStructMemberPubSubType::CompleteStructMemberPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteStructMember"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteStructMember::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteStructMember_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteStructMember"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteStructMember_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteStructMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteStructMember_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteStructMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteStructMember_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteStructMemberPubSubType::~CompleteStructMemberPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteStructMemberPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteStructMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3986,16 +3719,12 @@ bool CompleteStructMemberPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteStructMemberPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4004,18 +3733,14 @@ bool CompleteStructMemberPubSubType::deserialize( CompleteStructMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4028,52 +3753,62 @@ bool CompleteStructMemberPubSubType::deserialize( return true; } -std::function CompleteStructMemberPubSubType::getSerializedSizeProvider( +uint32_t CompleteStructMemberPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteStructMemberPubSubType::createData() + 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* CompleteStructMemberPubSubType::create_data() { return reinterpret_cast(new CompleteStructMember()); } -void CompleteStructMemberPubSubType::deleteData( +void CompleteStructMemberPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteStructMemberPubSubType::getKey( +bool CompleteStructMemberPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteStructMember data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteStructMemberPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4081,35 +3816,27 @@ bool CompleteStructMemberPubSubType::getKey( const CompleteStructMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteStructMember_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteStructMember_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4124,49 +3851,42 @@ void CompleteStructMemberPubSubType::register_type_object_representation() MinimalStructMemberPubSubType::MinimalStructMemberPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalStructMember"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalStructMember::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalStructMember_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalStructMember"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalStructMember_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalStructMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalStructMember_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalStructMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalStructMember_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalStructMemberPubSubType::~MinimalStructMemberPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalStructMemberPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalStructMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4181,16 +3901,12 @@ bool MinimalStructMemberPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalStructMemberPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4199,18 +3915,14 @@ bool MinimalStructMemberPubSubType::deserialize( MinimalStructMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4223,52 +3935,62 @@ bool MinimalStructMemberPubSubType::deserialize( return true; } -std::function MinimalStructMemberPubSubType::getSerializedSizeProvider( +uint32_t MinimalStructMemberPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalStructMemberPubSubType::createData() + 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* MinimalStructMemberPubSubType::create_data() { return reinterpret_cast(new MinimalStructMember()); } -void MinimalStructMemberPubSubType::deleteData( +void MinimalStructMemberPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalStructMemberPubSubType::getKey( +bool MinimalStructMemberPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalStructMember data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalStructMemberPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4276,35 +3998,27 @@ bool MinimalStructMemberPubSubType::getKey( const MinimalStructMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalStructMember_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalStructMember_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4319,49 +4033,42 @@ void MinimalStructMemberPubSubType::register_type_object_representation() AppliedBuiltinTypeAnnotationsPubSubType::AppliedBuiltinTypeAnnotationsPubSubType() { - setName("eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppliedBuiltinTypeAnnotations::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_AppliedBuiltinTypeAnnotations_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_AppliedBuiltinTypeAnnotations_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_AppliedBuiltinTypeAnnotations_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_AppliedBuiltinTypeAnnotations_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_AppliedBuiltinTypeAnnotations_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_AppliedBuiltinTypeAnnotations_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppliedBuiltinTypeAnnotationsPubSubType::~AppliedBuiltinTypeAnnotationsPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppliedBuiltinTypeAnnotationsPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppliedBuiltinTypeAnnotations* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4376,16 +4083,12 @@ bool AppliedBuiltinTypeAnnotationsPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppliedBuiltinTypeAnnotationsPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4394,18 +4097,14 @@ bool AppliedBuiltinTypeAnnotationsPubSubType::deserialize( AppliedBuiltinTypeAnnotations* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4418,52 +4117,62 @@ bool AppliedBuiltinTypeAnnotationsPubSubType::deserialize( return true; } -std::function AppliedBuiltinTypeAnnotationsPubSubType::getSerializedSizeProvider( +uint32_t AppliedBuiltinTypeAnnotationsPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppliedBuiltinTypeAnnotationsPubSubType::createData() + 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* AppliedBuiltinTypeAnnotationsPubSubType::create_data() { return reinterpret_cast(new AppliedBuiltinTypeAnnotations()); } -void AppliedBuiltinTypeAnnotationsPubSubType::deleteData( +void AppliedBuiltinTypeAnnotationsPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppliedBuiltinTypeAnnotationsPubSubType::getKey( +bool AppliedBuiltinTypeAnnotationsPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppliedBuiltinTypeAnnotations data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppliedBuiltinTypeAnnotationsPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4471,35 +4180,27 @@ bool AppliedBuiltinTypeAnnotationsPubSubType::getKey( const AppliedBuiltinTypeAnnotations* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_AppliedBuiltinTypeAnnotations_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_AppliedBuiltinTypeAnnotations_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4513,49 +4214,42 @@ void AppliedBuiltinTypeAnnotationsPubSubType::register_type_object_representatio MinimalTypeDetailPubSubType::MinimalTypeDetailPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalTypeDetail"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalTypeDetail::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalTypeDetail_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalTypeDetail"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalTypeDetail_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalTypeDetail_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalTypeDetail_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalTypeDetail_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalTypeDetail_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalTypeDetailPubSubType::~MinimalTypeDetailPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalTypeDetailPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalTypeDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4570,16 +4264,12 @@ bool MinimalTypeDetailPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalTypeDetailPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4588,18 +4278,14 @@ bool MinimalTypeDetailPubSubType::deserialize( MinimalTypeDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4612,52 +4298,62 @@ bool MinimalTypeDetailPubSubType::deserialize( return true; } -std::function MinimalTypeDetailPubSubType::getSerializedSizeProvider( +uint32_t MinimalTypeDetailPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalTypeDetailPubSubType::createData() + 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* MinimalTypeDetailPubSubType::create_data() { return reinterpret_cast(new MinimalTypeDetail()); } -void MinimalTypeDetailPubSubType::deleteData( +void MinimalTypeDetailPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalTypeDetailPubSubType::getKey( +bool MinimalTypeDetailPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalTypeDetail data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalTypeDetailPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4665,35 +4361,27 @@ bool MinimalTypeDetailPubSubType::getKey( const MinimalTypeDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalTypeDetail_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalTypeDetail_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4707,49 +4395,42 @@ void MinimalTypeDetailPubSubType::register_type_object_representation() CompleteTypeDetailPubSubType::CompleteTypeDetailPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteTypeDetail"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteTypeDetail::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteTypeDetail_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteTypeDetail"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteTypeDetail_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteTypeDetail_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteTypeDetail_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteTypeDetail_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteTypeDetail_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteTypeDetailPubSubType::~CompleteTypeDetailPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteTypeDetailPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteTypeDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4764,16 +4445,12 @@ bool CompleteTypeDetailPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteTypeDetailPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4782,18 +4459,14 @@ bool CompleteTypeDetailPubSubType::deserialize( CompleteTypeDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4806,52 +4479,62 @@ bool CompleteTypeDetailPubSubType::deserialize( return true; } -std::function CompleteTypeDetailPubSubType::getSerializedSizeProvider( +uint32_t CompleteTypeDetailPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteTypeDetailPubSubType::createData() + 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* CompleteTypeDetailPubSubType::create_data() { return reinterpret_cast(new CompleteTypeDetail()); } -void CompleteTypeDetailPubSubType::deleteData( +void CompleteTypeDetailPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteTypeDetailPubSubType::getKey( +bool CompleteTypeDetailPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteTypeDetail data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteTypeDetailPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4859,35 +4542,27 @@ bool CompleteTypeDetailPubSubType::getKey( const CompleteTypeDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteTypeDetail_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteTypeDetail_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4901,49 +4576,42 @@ void CompleteTypeDetailPubSubType::register_type_object_representation() CompleteStructHeaderPubSubType::CompleteStructHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteStructHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteStructHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteStructHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteStructHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteStructHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteStructHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteStructHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteStructHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteStructHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteStructHeaderPubSubType::~CompleteStructHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteStructHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteStructHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4958,16 +4626,12 @@ bool CompleteStructHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteStructHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4976,18 +4640,14 @@ bool CompleteStructHeaderPubSubType::deserialize( CompleteStructHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5000,52 +4660,62 @@ bool CompleteStructHeaderPubSubType::deserialize( return true; } -std::function CompleteStructHeaderPubSubType::getSerializedSizeProvider( +uint32_t CompleteStructHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteStructHeaderPubSubType::createData() -{ - return reinterpret_cast(new CompleteStructHeader()); -} - -void CompleteStructHeaderPubSubType::deleteData( + 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* CompleteStructHeaderPubSubType::create_data() +{ + return reinterpret_cast(new CompleteStructHeader()); +} + +void CompleteStructHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteStructHeaderPubSubType::getKey( +bool CompleteStructHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteStructHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteStructHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5053,35 +4723,27 @@ bool CompleteStructHeaderPubSubType::getKey( const CompleteStructHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteStructHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteStructHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5095,49 +4757,42 @@ void CompleteStructHeaderPubSubType::register_type_object_representation() MinimalStructHeaderPubSubType::MinimalStructHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalStructHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalStructHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalStructHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalStructHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalStructHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalStructHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalStructHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalStructHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalStructHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalStructHeaderPubSubType::~MinimalStructHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalStructHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalStructHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5152,16 +4807,12 @@ bool MinimalStructHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalStructHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5170,18 +4821,14 @@ bool MinimalStructHeaderPubSubType::deserialize( MinimalStructHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5194,52 +4841,62 @@ bool MinimalStructHeaderPubSubType::deserialize( return true; } -std::function MinimalStructHeaderPubSubType::getSerializedSizeProvider( +uint32_t MinimalStructHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalStructHeaderPubSubType::createData() + 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* MinimalStructHeaderPubSubType::create_data() { return reinterpret_cast(new MinimalStructHeader()); } -void MinimalStructHeaderPubSubType::deleteData( +void MinimalStructHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalStructHeaderPubSubType::getKey( +bool MinimalStructHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalStructHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalStructHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5247,35 +4904,27 @@ bool MinimalStructHeaderPubSubType::getKey( const MinimalStructHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalStructHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalStructHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5289,49 +4938,42 @@ void MinimalStructHeaderPubSubType::register_type_object_representation() CompleteStructTypePubSubType::CompleteStructTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteStructType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteStructType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteStructType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteStructType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteStructType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteStructType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteStructType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteStructType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteStructType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteStructTypePubSubType::~CompleteStructTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteStructTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteStructType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5346,16 +4988,12 @@ bool CompleteStructTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteStructTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5364,18 +5002,14 @@ bool CompleteStructTypePubSubType::deserialize( CompleteStructType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5388,52 +5022,62 @@ bool CompleteStructTypePubSubType::deserialize( return true; } -std::function CompleteStructTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteStructTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteStructTypePubSubType::createData() + 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* CompleteStructTypePubSubType::create_data() { return reinterpret_cast(new CompleteStructType()); } -void CompleteStructTypePubSubType::deleteData( +void CompleteStructTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteStructTypePubSubType::getKey( +bool CompleteStructTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteStructType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteStructTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5441,35 +5085,27 @@ bool CompleteStructTypePubSubType::getKey( const CompleteStructType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteStructType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteStructType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5483,49 +5119,42 @@ void CompleteStructTypePubSubType::register_type_object_representation() MinimalStructTypePubSubType::MinimalStructTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalStructType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalStructType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalStructType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalStructType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalStructType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalStructType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalStructType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalStructType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalStructType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalStructTypePubSubType::~MinimalStructTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalStructTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalStructType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5540,16 +5169,12 @@ bool MinimalStructTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalStructTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5558,18 +5183,14 @@ bool MinimalStructTypePubSubType::deserialize( MinimalStructType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5582,52 +5203,62 @@ bool MinimalStructTypePubSubType::deserialize( return true; } -std::function MinimalStructTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalStructTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalStructTypePubSubType::createData() + 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* MinimalStructTypePubSubType::create_data() { return reinterpret_cast(new MinimalStructType()); } -void MinimalStructTypePubSubType::deleteData( +void MinimalStructTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalStructTypePubSubType::getKey( +bool MinimalStructTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalStructType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalStructTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5635,35 +5266,27 @@ bool MinimalStructTypePubSubType::getKey( const MinimalStructType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalStructType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalStructType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5678,49 +5301,42 @@ void MinimalStructTypePubSubType::register_type_object_representation() CommonUnionMemberPubSubType::CommonUnionMemberPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonUnionMember"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonUnionMember::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonUnionMember_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonUnionMember"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonUnionMember_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonUnionMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonUnionMember_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonUnionMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonUnionMember_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonUnionMemberPubSubType::~CommonUnionMemberPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonUnionMemberPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonUnionMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5735,16 +5351,12 @@ bool CommonUnionMemberPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonUnionMemberPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5753,18 +5365,14 @@ bool CommonUnionMemberPubSubType::deserialize( CommonUnionMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5777,52 +5385,62 @@ bool CommonUnionMemberPubSubType::deserialize( return true; } -std::function CommonUnionMemberPubSubType::getSerializedSizeProvider( +uint32_t CommonUnionMemberPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonUnionMemberPubSubType::createData() + 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* CommonUnionMemberPubSubType::create_data() { return reinterpret_cast(new CommonUnionMember()); } -void CommonUnionMemberPubSubType::deleteData( +void CommonUnionMemberPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonUnionMemberPubSubType::getKey( +bool CommonUnionMemberPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonUnionMember data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonUnionMemberPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5830,35 +5448,27 @@ bool CommonUnionMemberPubSubType::getKey( const CommonUnionMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonUnionMember_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonUnionMember_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5872,49 +5482,42 @@ void CommonUnionMemberPubSubType::register_type_object_representation() CompleteUnionMemberPubSubType::CompleteUnionMemberPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteUnionMember"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteUnionMember::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteUnionMember_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteUnionMember"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteUnionMember_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteUnionMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteUnionMember_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteUnionMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteUnionMember_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteUnionMemberPubSubType::~CompleteUnionMemberPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteUnionMemberPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteUnionMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5929,16 +5532,12 @@ bool CompleteUnionMemberPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteUnionMemberPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5947,18 +5546,14 @@ bool CompleteUnionMemberPubSubType::deserialize( CompleteUnionMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5971,52 +5566,62 @@ bool CompleteUnionMemberPubSubType::deserialize( return true; } -std::function CompleteUnionMemberPubSubType::getSerializedSizeProvider( +uint32_t CompleteUnionMemberPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteUnionMemberPubSubType::createData() + 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* CompleteUnionMemberPubSubType::create_data() { return reinterpret_cast(new CompleteUnionMember()); } -void CompleteUnionMemberPubSubType::deleteData( +void CompleteUnionMemberPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteUnionMemberPubSubType::getKey( +bool CompleteUnionMemberPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteUnionMember data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteUnionMemberPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6024,35 +5629,27 @@ bool CompleteUnionMemberPubSubType::getKey( const CompleteUnionMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteUnionMember_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteUnionMember_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6067,49 +5664,42 @@ void CompleteUnionMemberPubSubType::register_type_object_representation() MinimalUnionMemberPubSubType::MinimalUnionMemberPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalUnionMember"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalUnionMember::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalUnionMember_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalUnionMember"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalUnionMember_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalUnionMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalUnionMember_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalUnionMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalUnionMember_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalUnionMemberPubSubType::~MinimalUnionMemberPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalUnionMemberPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalUnionMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6124,16 +5714,12 @@ bool MinimalUnionMemberPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalUnionMemberPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6142,18 +5728,14 @@ bool MinimalUnionMemberPubSubType::deserialize( MinimalUnionMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6166,52 +5748,62 @@ bool MinimalUnionMemberPubSubType::deserialize( return true; } -std::function MinimalUnionMemberPubSubType::getSerializedSizeProvider( +uint32_t MinimalUnionMemberPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalUnionMemberPubSubType::createData() + 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* MinimalUnionMemberPubSubType::create_data() { return reinterpret_cast(new MinimalUnionMember()); } -void MinimalUnionMemberPubSubType::deleteData( +void MinimalUnionMemberPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalUnionMemberPubSubType::getKey( +bool MinimalUnionMemberPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalUnionMember data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalUnionMemberPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6219,35 +5811,27 @@ bool MinimalUnionMemberPubSubType::getKey( const MinimalUnionMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalUnionMember_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalUnionMember_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6262,49 +5846,42 @@ void MinimalUnionMemberPubSubType::register_type_object_representation() CommonDiscriminatorMemberPubSubType::CommonDiscriminatorMemberPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonDiscriminatorMember"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonDiscriminatorMember::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonDiscriminatorMember_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonDiscriminatorMember"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonDiscriminatorMember_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonDiscriminatorMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonDiscriminatorMember_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonDiscriminatorMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonDiscriminatorMember_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonDiscriminatorMemberPubSubType::~CommonDiscriminatorMemberPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonDiscriminatorMemberPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonDiscriminatorMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6319,16 +5896,12 @@ bool CommonDiscriminatorMemberPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonDiscriminatorMemberPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6337,18 +5910,14 @@ bool CommonDiscriminatorMemberPubSubType::deserialize( CommonDiscriminatorMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6361,52 +5930,62 @@ bool CommonDiscriminatorMemberPubSubType::deserialize( return true; } -std::function CommonDiscriminatorMemberPubSubType::getSerializedSizeProvider( +uint32_t CommonDiscriminatorMemberPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonDiscriminatorMemberPubSubType::createData() + 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* CommonDiscriminatorMemberPubSubType::create_data() { return reinterpret_cast(new CommonDiscriminatorMember()); } -void CommonDiscriminatorMemberPubSubType::deleteData( +void CommonDiscriminatorMemberPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonDiscriminatorMemberPubSubType::getKey( +bool CommonDiscriminatorMemberPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonDiscriminatorMember data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonDiscriminatorMemberPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6414,35 +5993,27 @@ bool CommonDiscriminatorMemberPubSubType::getKey( const CommonDiscriminatorMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonDiscriminatorMember_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonDiscriminatorMember_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6456,49 +6027,42 @@ void CommonDiscriminatorMemberPubSubType::register_type_object_representation() CompleteDiscriminatorMemberPubSubType::CompleteDiscriminatorMemberPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteDiscriminatorMember"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteDiscriminatorMember::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteDiscriminatorMember_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteDiscriminatorMember"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteDiscriminatorMember_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteDiscriminatorMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteDiscriminatorMember_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteDiscriminatorMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteDiscriminatorMember_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteDiscriminatorMemberPubSubType::~CompleteDiscriminatorMemberPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteDiscriminatorMemberPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteDiscriminatorMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6513,16 +6077,12 @@ bool CompleteDiscriminatorMemberPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteDiscriminatorMemberPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6531,18 +6091,14 @@ bool CompleteDiscriminatorMemberPubSubType::deserialize( CompleteDiscriminatorMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6555,52 +6111,62 @@ bool CompleteDiscriminatorMemberPubSubType::deserialize( return true; } -std::function CompleteDiscriminatorMemberPubSubType::getSerializedSizeProvider( +uint32_t CompleteDiscriminatorMemberPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteDiscriminatorMemberPubSubType::createData() + 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* CompleteDiscriminatorMemberPubSubType::create_data() { return reinterpret_cast(new CompleteDiscriminatorMember()); } -void CompleteDiscriminatorMemberPubSubType::deleteData( +void CompleteDiscriminatorMemberPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteDiscriminatorMemberPubSubType::getKey( +bool CompleteDiscriminatorMemberPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteDiscriminatorMember data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteDiscriminatorMemberPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6608,35 +6174,27 @@ bool CompleteDiscriminatorMemberPubSubType::getKey( const CompleteDiscriminatorMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteDiscriminatorMember_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteDiscriminatorMember_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6650,49 +6208,42 @@ void CompleteDiscriminatorMemberPubSubType::register_type_object_representation( MinimalDiscriminatorMemberPubSubType::MinimalDiscriminatorMemberPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalDiscriminatorMember"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalDiscriminatorMember::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalDiscriminatorMember_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalDiscriminatorMember"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalDiscriminatorMember_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalDiscriminatorMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalDiscriminatorMember_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalDiscriminatorMember_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalDiscriminatorMember_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalDiscriminatorMemberPubSubType::~MinimalDiscriminatorMemberPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalDiscriminatorMemberPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalDiscriminatorMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6707,16 +6258,12 @@ bool MinimalDiscriminatorMemberPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalDiscriminatorMemberPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6725,18 +6272,14 @@ bool MinimalDiscriminatorMemberPubSubType::deserialize( MinimalDiscriminatorMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6749,52 +6292,62 @@ bool MinimalDiscriminatorMemberPubSubType::deserialize( return true; } -std::function MinimalDiscriminatorMemberPubSubType::getSerializedSizeProvider( +uint32_t MinimalDiscriminatorMemberPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalDiscriminatorMemberPubSubType::createData() + 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* MinimalDiscriminatorMemberPubSubType::create_data() { return reinterpret_cast(new MinimalDiscriminatorMember()); } -void MinimalDiscriminatorMemberPubSubType::deleteData( +void MinimalDiscriminatorMemberPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalDiscriminatorMemberPubSubType::getKey( +bool MinimalDiscriminatorMemberPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalDiscriminatorMember data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalDiscriminatorMemberPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6802,35 +6355,27 @@ bool MinimalDiscriminatorMemberPubSubType::getKey( const MinimalDiscriminatorMember* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalDiscriminatorMember_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalDiscriminatorMember_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6844,49 +6389,42 @@ void MinimalDiscriminatorMemberPubSubType::register_type_object_representation() CompleteUnionHeaderPubSubType::CompleteUnionHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteUnionHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteUnionHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteUnionHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteUnionHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteUnionHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteUnionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteUnionHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteUnionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteUnionHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteUnionHeaderPubSubType::~CompleteUnionHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteUnionHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteUnionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6901,16 +6439,12 @@ bool CompleteUnionHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteUnionHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6919,18 +6453,14 @@ bool CompleteUnionHeaderPubSubType::deserialize( CompleteUnionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6943,52 +6473,62 @@ bool CompleteUnionHeaderPubSubType::deserialize( return true; } -std::function CompleteUnionHeaderPubSubType::getSerializedSizeProvider( +uint32_t CompleteUnionHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteUnionHeaderPubSubType::createData() + 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* CompleteUnionHeaderPubSubType::create_data() { return reinterpret_cast(new CompleteUnionHeader()); } -void CompleteUnionHeaderPubSubType::deleteData( +void CompleteUnionHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteUnionHeaderPubSubType::getKey( +bool CompleteUnionHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteUnionHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteUnionHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6996,35 +6536,27 @@ bool CompleteUnionHeaderPubSubType::getKey( const CompleteUnionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteUnionHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteUnionHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7038,49 +6570,42 @@ void CompleteUnionHeaderPubSubType::register_type_object_representation() MinimalUnionHeaderPubSubType::MinimalUnionHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalUnionHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalUnionHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalUnionHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalUnionHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalUnionHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalUnionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalUnionHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalUnionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalUnionHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalUnionHeaderPubSubType::~MinimalUnionHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalUnionHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalUnionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7095,16 +6620,12 @@ bool MinimalUnionHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalUnionHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7113,18 +6634,14 @@ bool MinimalUnionHeaderPubSubType::deserialize( MinimalUnionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7137,52 +6654,62 @@ bool MinimalUnionHeaderPubSubType::deserialize( return true; } -std::function MinimalUnionHeaderPubSubType::getSerializedSizeProvider( +uint32_t MinimalUnionHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalUnionHeaderPubSubType::createData() + 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* MinimalUnionHeaderPubSubType::create_data() { return reinterpret_cast(new MinimalUnionHeader()); } -void MinimalUnionHeaderPubSubType::deleteData( +void MinimalUnionHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalUnionHeaderPubSubType::getKey( +bool MinimalUnionHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalUnionHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalUnionHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7190,35 +6717,27 @@ bool MinimalUnionHeaderPubSubType::getKey( const MinimalUnionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalUnionHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalUnionHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7232,49 +6751,42 @@ void MinimalUnionHeaderPubSubType::register_type_object_representation() CompleteUnionTypePubSubType::CompleteUnionTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteUnionType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteUnionType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteUnionType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteUnionType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteUnionType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteUnionType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteUnionType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteUnionType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteUnionType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteUnionTypePubSubType::~CompleteUnionTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteUnionTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteUnionType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7289,16 +6801,12 @@ bool CompleteUnionTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteUnionTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7307,18 +6815,14 @@ bool CompleteUnionTypePubSubType::deserialize( CompleteUnionType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7331,52 +6835,62 @@ bool CompleteUnionTypePubSubType::deserialize( return true; } -std::function CompleteUnionTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteUnionTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteUnionTypePubSubType::createData() + 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* CompleteUnionTypePubSubType::create_data() { return reinterpret_cast(new CompleteUnionType()); } -void CompleteUnionTypePubSubType::deleteData( +void CompleteUnionTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteUnionTypePubSubType::getKey( +bool CompleteUnionTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteUnionType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteUnionTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7384,35 +6898,27 @@ bool CompleteUnionTypePubSubType::getKey( const CompleteUnionType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteUnionType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteUnionType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7426,49 +6932,42 @@ void CompleteUnionTypePubSubType::register_type_object_representation() MinimalUnionTypePubSubType::MinimalUnionTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalUnionType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalUnionType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalUnionType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalUnionType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalUnionType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalUnionType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalUnionType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalUnionType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalUnionType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalUnionTypePubSubType::~MinimalUnionTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalUnionTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalUnionType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7483,16 +6982,12 @@ bool MinimalUnionTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalUnionTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7501,18 +6996,14 @@ bool MinimalUnionTypePubSubType::deserialize( MinimalUnionType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7525,52 +7016,62 @@ bool MinimalUnionTypePubSubType::deserialize( return true; } -std::function MinimalUnionTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalUnionTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalUnionTypePubSubType::createData() + 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* MinimalUnionTypePubSubType::create_data() { return reinterpret_cast(new MinimalUnionType()); } -void MinimalUnionTypePubSubType::deleteData( +void MinimalUnionTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalUnionTypePubSubType::getKey( +bool MinimalUnionTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalUnionType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalUnionTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7578,35 +7079,27 @@ bool MinimalUnionTypePubSubType::getKey( const MinimalUnionType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalUnionType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalUnionType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7620,49 +7113,42 @@ void MinimalUnionTypePubSubType::register_type_object_representation() CommonAnnotationParameterPubSubType::CommonAnnotationParameterPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonAnnotationParameter"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonAnnotationParameter::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonAnnotationParameter_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonAnnotationParameter"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonAnnotationParameter_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonAnnotationParameter_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonAnnotationParameter_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonAnnotationParameter_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonAnnotationParameter_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonAnnotationParameterPubSubType::~CommonAnnotationParameterPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonAnnotationParameterPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7677,16 +7163,12 @@ bool CommonAnnotationParameterPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonAnnotationParameterPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7695,18 +7177,14 @@ bool CommonAnnotationParameterPubSubType::deserialize( CommonAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7719,52 +7197,62 @@ bool CommonAnnotationParameterPubSubType::deserialize( return true; } -std::function CommonAnnotationParameterPubSubType::getSerializedSizeProvider( +uint32_t CommonAnnotationParameterPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonAnnotationParameterPubSubType::createData() + 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* CommonAnnotationParameterPubSubType::create_data() { return reinterpret_cast(new CommonAnnotationParameter()); } -void CommonAnnotationParameterPubSubType::deleteData( +void CommonAnnotationParameterPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonAnnotationParameterPubSubType::getKey( +bool CommonAnnotationParameterPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonAnnotationParameter data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonAnnotationParameterPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7772,35 +7260,27 @@ bool CommonAnnotationParameterPubSubType::getKey( const CommonAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonAnnotationParameter_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonAnnotationParameter_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7814,49 +7294,42 @@ void CommonAnnotationParameterPubSubType::register_type_object_representation() CompleteAnnotationParameterPubSubType::CompleteAnnotationParameterPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteAnnotationParameter"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteAnnotationParameter::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteAnnotationParameter_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteAnnotationParameter"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteAnnotationParameter_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteAnnotationParameter_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAnnotationParameter_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteAnnotationParameter_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAnnotationParameter_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteAnnotationParameterPubSubType::~CompleteAnnotationParameterPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteAnnotationParameterPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7871,16 +7344,12 @@ bool CompleteAnnotationParameterPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteAnnotationParameterPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7889,18 +7358,14 @@ bool CompleteAnnotationParameterPubSubType::deserialize( CompleteAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7913,52 +7378,62 @@ bool CompleteAnnotationParameterPubSubType::deserialize( return true; } -std::function CompleteAnnotationParameterPubSubType::getSerializedSizeProvider( +uint32_t CompleteAnnotationParameterPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteAnnotationParameterPubSubType::createData() + 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* CompleteAnnotationParameterPubSubType::create_data() { return reinterpret_cast(new CompleteAnnotationParameter()); } -void CompleteAnnotationParameterPubSubType::deleteData( +void CompleteAnnotationParameterPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteAnnotationParameterPubSubType::getKey( +bool CompleteAnnotationParameterPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteAnnotationParameter data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteAnnotationParameterPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7966,35 +7441,27 @@ bool CompleteAnnotationParameterPubSubType::getKey( const CompleteAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteAnnotationParameter_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteAnnotationParameter_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8009,49 +7476,42 @@ void CompleteAnnotationParameterPubSubType::register_type_object_representation( MinimalAnnotationParameterPubSubType::MinimalAnnotationParameterPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalAnnotationParameter"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalAnnotationParameter::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalAnnotationParameter_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalAnnotationParameter"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalAnnotationParameter_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalAnnotationParameter_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAnnotationParameter_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalAnnotationParameter_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAnnotationParameter_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalAnnotationParameterPubSubType::~MinimalAnnotationParameterPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalAnnotationParameterPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8066,16 +7526,12 @@ bool MinimalAnnotationParameterPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalAnnotationParameterPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8084,18 +7540,14 @@ bool MinimalAnnotationParameterPubSubType::deserialize( MinimalAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8108,52 +7560,62 @@ bool MinimalAnnotationParameterPubSubType::deserialize( return true; } -std::function MinimalAnnotationParameterPubSubType::getSerializedSizeProvider( +uint32_t MinimalAnnotationParameterPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalAnnotationParameterPubSubType::createData() + 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* MinimalAnnotationParameterPubSubType::create_data() { return reinterpret_cast(new MinimalAnnotationParameter()); } -void MinimalAnnotationParameterPubSubType::deleteData( +void MinimalAnnotationParameterPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalAnnotationParameterPubSubType::getKey( +bool MinimalAnnotationParameterPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalAnnotationParameter data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalAnnotationParameterPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8161,35 +7623,27 @@ bool MinimalAnnotationParameterPubSubType::getKey( const MinimalAnnotationParameter* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalAnnotationParameter_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalAnnotationParameter_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8204,49 +7658,42 @@ void MinimalAnnotationParameterPubSubType::register_type_object_representation() CompleteAnnotationHeaderPubSubType::CompleteAnnotationHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteAnnotationHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteAnnotationHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteAnnotationHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteAnnotationHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteAnnotationHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteAnnotationHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAnnotationHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteAnnotationHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAnnotationHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteAnnotationHeaderPubSubType::~CompleteAnnotationHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteAnnotationHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteAnnotationHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8261,16 +7708,12 @@ bool CompleteAnnotationHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteAnnotationHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8279,18 +7722,14 @@ bool CompleteAnnotationHeaderPubSubType::deserialize( CompleteAnnotationHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8303,52 +7742,62 @@ bool CompleteAnnotationHeaderPubSubType::deserialize( return true; } -std::function CompleteAnnotationHeaderPubSubType::getSerializedSizeProvider( +uint32_t CompleteAnnotationHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteAnnotationHeaderPubSubType::createData() + 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* CompleteAnnotationHeaderPubSubType::create_data() { return reinterpret_cast(new CompleteAnnotationHeader()); } -void CompleteAnnotationHeaderPubSubType::deleteData( +void CompleteAnnotationHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteAnnotationHeaderPubSubType::getKey( +bool CompleteAnnotationHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteAnnotationHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteAnnotationHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8356,35 +7805,27 @@ bool CompleteAnnotationHeaderPubSubType::getKey( const CompleteAnnotationHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteAnnotationHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteAnnotationHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8398,49 +7839,42 @@ void CompleteAnnotationHeaderPubSubType::register_type_object_representation() MinimalAnnotationHeaderPubSubType::MinimalAnnotationHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalAnnotationHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalAnnotationHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalAnnotationHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalAnnotationHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalAnnotationHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalAnnotationHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAnnotationHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalAnnotationHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAnnotationHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalAnnotationHeaderPubSubType::~MinimalAnnotationHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalAnnotationHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalAnnotationHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8455,16 +7889,12 @@ bool MinimalAnnotationHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalAnnotationHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8473,18 +7903,14 @@ bool MinimalAnnotationHeaderPubSubType::deserialize( MinimalAnnotationHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8497,52 +7923,62 @@ bool MinimalAnnotationHeaderPubSubType::deserialize( return true; } -std::function MinimalAnnotationHeaderPubSubType::getSerializedSizeProvider( +uint32_t MinimalAnnotationHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalAnnotationHeaderPubSubType::createData() + 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* MinimalAnnotationHeaderPubSubType::create_data() { return reinterpret_cast(new MinimalAnnotationHeader()); } -void MinimalAnnotationHeaderPubSubType::deleteData( +void MinimalAnnotationHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalAnnotationHeaderPubSubType::getKey( +bool MinimalAnnotationHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalAnnotationHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalAnnotationHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8550,35 +7986,27 @@ bool MinimalAnnotationHeaderPubSubType::getKey( const MinimalAnnotationHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalAnnotationHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalAnnotationHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8592,49 +8020,42 @@ void MinimalAnnotationHeaderPubSubType::register_type_object_representation() CompleteAnnotationTypePubSubType::CompleteAnnotationTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteAnnotationType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteAnnotationType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteAnnotationType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteAnnotationType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteAnnotationType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteAnnotationType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAnnotationType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteAnnotationType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAnnotationType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteAnnotationTypePubSubType::~CompleteAnnotationTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteAnnotationTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteAnnotationType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8649,16 +8070,12 @@ bool CompleteAnnotationTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteAnnotationTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8667,18 +8084,14 @@ bool CompleteAnnotationTypePubSubType::deserialize( CompleteAnnotationType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8691,52 +8104,62 @@ bool CompleteAnnotationTypePubSubType::deserialize( return true; } -std::function CompleteAnnotationTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteAnnotationTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteAnnotationTypePubSubType::createData() + 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* CompleteAnnotationTypePubSubType::create_data() { return reinterpret_cast(new CompleteAnnotationType()); } -void CompleteAnnotationTypePubSubType::deleteData( +void CompleteAnnotationTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteAnnotationTypePubSubType::getKey( +bool CompleteAnnotationTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteAnnotationType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteAnnotationTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8744,35 +8167,27 @@ bool CompleteAnnotationTypePubSubType::getKey( const CompleteAnnotationType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteAnnotationType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteAnnotationType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8786,49 +8201,42 @@ void CompleteAnnotationTypePubSubType::register_type_object_representation() MinimalAnnotationTypePubSubType::MinimalAnnotationTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalAnnotationType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalAnnotationType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalAnnotationType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalAnnotationType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalAnnotationType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalAnnotationType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAnnotationType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalAnnotationType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAnnotationType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalAnnotationTypePubSubType::~MinimalAnnotationTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalAnnotationTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalAnnotationType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8843,16 +8251,12 @@ bool MinimalAnnotationTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalAnnotationTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8861,18 +8265,14 @@ bool MinimalAnnotationTypePubSubType::deserialize( MinimalAnnotationType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8885,52 +8285,62 @@ bool MinimalAnnotationTypePubSubType::deserialize( return true; } -std::function MinimalAnnotationTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalAnnotationTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalAnnotationTypePubSubType::createData() + 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* MinimalAnnotationTypePubSubType::create_data() { return reinterpret_cast(new MinimalAnnotationType()); } -void MinimalAnnotationTypePubSubType::deleteData( +void MinimalAnnotationTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalAnnotationTypePubSubType::getKey( +bool MinimalAnnotationTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalAnnotationType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalAnnotationTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8938,35 +8348,27 @@ bool MinimalAnnotationTypePubSubType::getKey( const MinimalAnnotationType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalAnnotationType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalAnnotationType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8980,49 +8382,42 @@ void MinimalAnnotationTypePubSubType::register_type_object_representation() CommonAliasBodyPubSubType::CommonAliasBodyPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonAliasBody"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonAliasBody::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonAliasBody_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonAliasBody"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonAliasBody_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonAliasBody_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonAliasBody_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonAliasBody_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonAliasBody_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonAliasBodyPubSubType::~CommonAliasBodyPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonAliasBodyPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonAliasBody* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9037,16 +8432,12 @@ bool CommonAliasBodyPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonAliasBodyPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9055,18 +8446,14 @@ bool CommonAliasBodyPubSubType::deserialize( CommonAliasBody* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9079,52 +8466,62 @@ bool CommonAliasBodyPubSubType::deserialize( return true; } -std::function CommonAliasBodyPubSubType::getSerializedSizeProvider( +uint32_t CommonAliasBodyPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonAliasBodyPubSubType::createData() + 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* CommonAliasBodyPubSubType::create_data() { return reinterpret_cast(new CommonAliasBody()); } -void CommonAliasBodyPubSubType::deleteData( +void CommonAliasBodyPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonAliasBodyPubSubType::getKey( +bool CommonAliasBodyPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonAliasBody data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonAliasBodyPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9132,35 +8529,27 @@ bool CommonAliasBodyPubSubType::getKey( const CommonAliasBody* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonAliasBody_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonAliasBody_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9174,49 +8563,42 @@ void CommonAliasBodyPubSubType::register_type_object_representation() CompleteAliasBodyPubSubType::CompleteAliasBodyPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteAliasBody"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteAliasBody::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteAliasBody_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteAliasBody"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteAliasBody_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteAliasBody_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAliasBody_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteAliasBody_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAliasBody_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteAliasBodyPubSubType::~CompleteAliasBodyPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteAliasBodyPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteAliasBody* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9231,16 +8613,12 @@ bool CompleteAliasBodyPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteAliasBodyPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9249,18 +8627,14 @@ bool CompleteAliasBodyPubSubType::deserialize( CompleteAliasBody* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9273,52 +8647,62 @@ bool CompleteAliasBodyPubSubType::deserialize( return true; } -std::function CompleteAliasBodyPubSubType::getSerializedSizeProvider( +uint32_t CompleteAliasBodyPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteAliasBodyPubSubType::createData() + 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* CompleteAliasBodyPubSubType::create_data() { return reinterpret_cast(new CompleteAliasBody()); } -void CompleteAliasBodyPubSubType::deleteData( +void CompleteAliasBodyPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteAliasBodyPubSubType::getKey( +bool CompleteAliasBodyPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteAliasBody data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteAliasBodyPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9326,35 +8710,27 @@ bool CompleteAliasBodyPubSubType::getKey( const CompleteAliasBody* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteAliasBody_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteAliasBody_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9368,49 +8744,42 @@ void CompleteAliasBodyPubSubType::register_type_object_representation() MinimalAliasBodyPubSubType::MinimalAliasBodyPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalAliasBody"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalAliasBody::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalAliasBody_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalAliasBody"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalAliasBody_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalAliasBody_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAliasBody_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalAliasBody_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAliasBody_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalAliasBodyPubSubType::~MinimalAliasBodyPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalAliasBodyPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalAliasBody* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9425,16 +8794,12 @@ bool MinimalAliasBodyPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalAliasBodyPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9443,18 +8808,14 @@ bool MinimalAliasBodyPubSubType::deserialize( MinimalAliasBody* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9467,52 +8828,62 @@ bool MinimalAliasBodyPubSubType::deserialize( return true; } -std::function MinimalAliasBodyPubSubType::getSerializedSizeProvider( +uint32_t MinimalAliasBodyPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalAliasBodyPubSubType::createData() + 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* MinimalAliasBodyPubSubType::create_data() { return reinterpret_cast(new MinimalAliasBody()); } -void MinimalAliasBodyPubSubType::deleteData( +void MinimalAliasBodyPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalAliasBodyPubSubType::getKey( +bool MinimalAliasBodyPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalAliasBody data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalAliasBodyPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9520,35 +8891,27 @@ bool MinimalAliasBodyPubSubType::getKey( const MinimalAliasBody* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalAliasBody_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalAliasBody_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9562,49 +8925,42 @@ void MinimalAliasBodyPubSubType::register_type_object_representation() CompleteAliasHeaderPubSubType::CompleteAliasHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteAliasHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteAliasHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteAliasHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteAliasHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteAliasHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteAliasHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAliasHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteAliasHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAliasHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteAliasHeaderPubSubType::~CompleteAliasHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteAliasHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteAliasHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9619,16 +8975,12 @@ bool CompleteAliasHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteAliasHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9637,18 +8989,14 @@ bool CompleteAliasHeaderPubSubType::deserialize( CompleteAliasHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9661,52 +9009,62 @@ bool CompleteAliasHeaderPubSubType::deserialize( return true; } -std::function CompleteAliasHeaderPubSubType::getSerializedSizeProvider( +uint32_t CompleteAliasHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteAliasHeaderPubSubType::createData() + 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* CompleteAliasHeaderPubSubType::create_data() { return reinterpret_cast(new CompleteAliasHeader()); } -void CompleteAliasHeaderPubSubType::deleteData( +void CompleteAliasHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteAliasHeaderPubSubType::getKey( +bool CompleteAliasHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteAliasHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteAliasHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9714,35 +9072,27 @@ bool CompleteAliasHeaderPubSubType::getKey( const CompleteAliasHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteAliasHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteAliasHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9756,49 +9106,42 @@ void CompleteAliasHeaderPubSubType::register_type_object_representation() MinimalAliasHeaderPubSubType::MinimalAliasHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalAliasHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalAliasHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalAliasHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalAliasHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalAliasHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalAliasHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAliasHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalAliasHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAliasHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalAliasHeaderPubSubType::~MinimalAliasHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalAliasHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalAliasHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9813,16 +9156,12 @@ bool MinimalAliasHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalAliasHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9831,18 +9170,14 @@ bool MinimalAliasHeaderPubSubType::deserialize( MinimalAliasHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9855,52 +9190,62 @@ bool MinimalAliasHeaderPubSubType::deserialize( return true; } -std::function MinimalAliasHeaderPubSubType::getSerializedSizeProvider( +uint32_t MinimalAliasHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalAliasHeaderPubSubType::createData() + 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* MinimalAliasHeaderPubSubType::create_data() { return reinterpret_cast(new MinimalAliasHeader()); } -void MinimalAliasHeaderPubSubType::deleteData( +void MinimalAliasHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalAliasHeaderPubSubType::getKey( +bool MinimalAliasHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalAliasHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalAliasHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9908,35 +9253,27 @@ bool MinimalAliasHeaderPubSubType::getKey( const MinimalAliasHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalAliasHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalAliasHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9950,49 +9287,42 @@ void MinimalAliasHeaderPubSubType::register_type_object_representation() CompleteAliasTypePubSubType::CompleteAliasTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteAliasType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteAliasType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteAliasType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteAliasType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteAliasType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteAliasType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAliasType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteAliasType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteAliasType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteAliasTypePubSubType::~CompleteAliasTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteAliasTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteAliasType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10007,16 +9337,12 @@ bool CompleteAliasTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteAliasTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10025,18 +9351,14 @@ bool CompleteAliasTypePubSubType::deserialize( CompleteAliasType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10049,52 +9371,62 @@ bool CompleteAliasTypePubSubType::deserialize( return true; } -std::function CompleteAliasTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteAliasTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteAliasTypePubSubType::createData() + 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* CompleteAliasTypePubSubType::create_data() { return reinterpret_cast(new CompleteAliasType()); } -void CompleteAliasTypePubSubType::deleteData( +void CompleteAliasTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteAliasTypePubSubType::getKey( +bool CompleteAliasTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteAliasType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteAliasTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10102,35 +9434,27 @@ bool CompleteAliasTypePubSubType::getKey( const CompleteAliasType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteAliasType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteAliasType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10144,49 +9468,42 @@ void CompleteAliasTypePubSubType::register_type_object_representation() MinimalAliasTypePubSubType::MinimalAliasTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalAliasType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalAliasType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalAliasType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalAliasType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalAliasType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalAliasType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAliasType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalAliasType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalAliasType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalAliasTypePubSubType::~MinimalAliasTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalAliasTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalAliasType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10201,16 +9518,12 @@ bool MinimalAliasTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalAliasTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10219,18 +9532,14 @@ bool MinimalAliasTypePubSubType::deserialize( MinimalAliasType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10243,52 +9552,62 @@ bool MinimalAliasTypePubSubType::deserialize( return true; } -std::function MinimalAliasTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalAliasTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalAliasTypePubSubType::createData() + 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* MinimalAliasTypePubSubType::create_data() { return reinterpret_cast(new MinimalAliasType()); } -void MinimalAliasTypePubSubType::deleteData( +void MinimalAliasTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalAliasTypePubSubType::getKey( +bool MinimalAliasTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalAliasType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalAliasTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10296,35 +9615,27 @@ bool MinimalAliasTypePubSubType::getKey( const MinimalAliasType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalAliasType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalAliasType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10338,49 +9649,42 @@ void MinimalAliasTypePubSubType::register_type_object_representation() CompleteElementDetailPubSubType::CompleteElementDetailPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteElementDetail"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteElementDetail::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteElementDetail_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteElementDetail"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteElementDetail_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteElementDetail_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteElementDetail_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteElementDetail_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteElementDetail_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteElementDetailPubSubType::~CompleteElementDetailPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteElementDetailPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteElementDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10395,16 +9699,12 @@ bool CompleteElementDetailPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteElementDetailPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10413,18 +9713,14 @@ bool CompleteElementDetailPubSubType::deserialize( CompleteElementDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10437,52 +9733,62 @@ bool CompleteElementDetailPubSubType::deserialize( return true; } -std::function CompleteElementDetailPubSubType::getSerializedSizeProvider( +uint32_t CompleteElementDetailPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteElementDetailPubSubType::createData() + 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* CompleteElementDetailPubSubType::create_data() { return reinterpret_cast(new CompleteElementDetail()); } -void CompleteElementDetailPubSubType::deleteData( +void CompleteElementDetailPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteElementDetailPubSubType::getKey( +bool CompleteElementDetailPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteElementDetail data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteElementDetailPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10490,35 +9796,27 @@ bool CompleteElementDetailPubSubType::getKey( const CompleteElementDetail* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteElementDetail_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteElementDetail_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10532,49 +9830,42 @@ void CompleteElementDetailPubSubType::register_type_object_representation() CommonCollectionElementPubSubType::CommonCollectionElementPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonCollectionElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonCollectionElement::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonCollectionElement_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonCollectionElement"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonCollectionElement_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonCollectionElement_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonCollectionElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonCollectionElement_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonCollectionElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonCollectionElementPubSubType::~CommonCollectionElementPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonCollectionElementPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonCollectionElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10589,16 +9880,12 @@ bool CommonCollectionElementPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonCollectionElementPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10607,18 +9894,14 @@ bool CommonCollectionElementPubSubType::deserialize( CommonCollectionElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10631,52 +9914,62 @@ bool CommonCollectionElementPubSubType::deserialize( return true; } -std::function CommonCollectionElementPubSubType::getSerializedSizeProvider( +uint32_t CommonCollectionElementPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonCollectionElementPubSubType::createData() + 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* CommonCollectionElementPubSubType::create_data() { return reinterpret_cast(new CommonCollectionElement()); } -void CommonCollectionElementPubSubType::deleteData( +void CommonCollectionElementPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonCollectionElementPubSubType::getKey( +bool CommonCollectionElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonCollectionElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonCollectionElementPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10684,35 +9977,27 @@ bool CommonCollectionElementPubSubType::getKey( const CommonCollectionElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonCollectionElement_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonCollectionElement_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10726,49 +10011,42 @@ void CommonCollectionElementPubSubType::register_type_object_representation() CompleteCollectionElementPubSubType::CompleteCollectionElementPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteCollectionElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteCollectionElement::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteCollectionElement_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteCollectionElement"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteCollectionElement_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteCollectionElement_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteCollectionElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteCollectionElement_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteCollectionElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteCollectionElementPubSubType::~CompleteCollectionElementPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteCollectionElementPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteCollectionElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10783,16 +10061,12 @@ bool CompleteCollectionElementPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteCollectionElementPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10801,18 +10075,14 @@ bool CompleteCollectionElementPubSubType::deserialize( CompleteCollectionElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10825,52 +10095,62 @@ bool CompleteCollectionElementPubSubType::deserialize( return true; } -std::function CompleteCollectionElementPubSubType::getSerializedSizeProvider( +uint32_t CompleteCollectionElementPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteCollectionElementPubSubType::createData() + 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* CompleteCollectionElementPubSubType::create_data() { return reinterpret_cast(new CompleteCollectionElement()); } -void CompleteCollectionElementPubSubType::deleteData( +void CompleteCollectionElementPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteCollectionElementPubSubType::getKey( +bool CompleteCollectionElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteCollectionElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteCollectionElementPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10878,35 +10158,27 @@ bool CompleteCollectionElementPubSubType::getKey( const CompleteCollectionElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteCollectionElement_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteCollectionElement_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10920,49 +10192,42 @@ void CompleteCollectionElementPubSubType::register_type_object_representation() MinimalCollectionElementPubSubType::MinimalCollectionElementPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalCollectionElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalCollectionElement::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalCollectionElement_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalCollectionElement"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalCollectionElement_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalCollectionElement_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalCollectionElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalCollectionElement_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalCollectionElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalCollectionElementPubSubType::~MinimalCollectionElementPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalCollectionElementPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalCollectionElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10977,16 +10242,12 @@ bool MinimalCollectionElementPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalCollectionElementPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10995,18 +10256,14 @@ bool MinimalCollectionElementPubSubType::deserialize( MinimalCollectionElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11019,52 +10276,62 @@ bool MinimalCollectionElementPubSubType::deserialize( return true; } -std::function MinimalCollectionElementPubSubType::getSerializedSizeProvider( +uint32_t MinimalCollectionElementPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalCollectionElementPubSubType::createData() + 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* MinimalCollectionElementPubSubType::create_data() { return reinterpret_cast(new MinimalCollectionElement()); } -void MinimalCollectionElementPubSubType::deleteData( +void MinimalCollectionElementPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalCollectionElementPubSubType::getKey( +bool MinimalCollectionElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalCollectionElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalCollectionElementPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11072,35 +10339,27 @@ bool MinimalCollectionElementPubSubType::getKey( const MinimalCollectionElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalCollectionElement_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalCollectionElement_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11114,49 +10373,42 @@ void MinimalCollectionElementPubSubType::register_type_object_representation() CommonCollectionHeaderPubSubType::CommonCollectionHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonCollectionHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonCollectionHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonCollectionHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonCollectionHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonCollectionHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonCollectionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonCollectionHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonCollectionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonCollectionHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonCollectionHeaderPubSubType::~CommonCollectionHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonCollectionHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11171,16 +10423,12 @@ bool CommonCollectionHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonCollectionHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11189,18 +10437,14 @@ bool CommonCollectionHeaderPubSubType::deserialize( CommonCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11213,52 +10457,62 @@ bool CommonCollectionHeaderPubSubType::deserialize( return true; } -std::function CommonCollectionHeaderPubSubType::getSerializedSizeProvider( +uint32_t CommonCollectionHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonCollectionHeaderPubSubType::createData() + 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* CommonCollectionHeaderPubSubType::create_data() { return reinterpret_cast(new CommonCollectionHeader()); } -void CommonCollectionHeaderPubSubType::deleteData( +void CommonCollectionHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonCollectionHeaderPubSubType::getKey( +bool CommonCollectionHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonCollectionHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonCollectionHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11266,35 +10520,27 @@ bool CommonCollectionHeaderPubSubType::getKey( const CommonCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonCollectionHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonCollectionHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11308,49 +10554,42 @@ void CommonCollectionHeaderPubSubType::register_type_object_representation() CompleteCollectionHeaderPubSubType::CompleteCollectionHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteCollectionHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteCollectionHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteCollectionHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteCollectionHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteCollectionHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteCollectionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteCollectionHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteCollectionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteCollectionHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteCollectionHeaderPubSubType::~CompleteCollectionHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteCollectionHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11365,16 +10604,12 @@ bool CompleteCollectionHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteCollectionHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11383,18 +10618,14 @@ bool CompleteCollectionHeaderPubSubType::deserialize( CompleteCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11407,52 +10638,62 @@ bool CompleteCollectionHeaderPubSubType::deserialize( return true; } -std::function CompleteCollectionHeaderPubSubType::getSerializedSizeProvider( +uint32_t CompleteCollectionHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteCollectionHeaderPubSubType::createData() + 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* CompleteCollectionHeaderPubSubType::create_data() { return reinterpret_cast(new CompleteCollectionHeader()); } -void CompleteCollectionHeaderPubSubType::deleteData( +void CompleteCollectionHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteCollectionHeaderPubSubType::getKey( +bool CompleteCollectionHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteCollectionHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteCollectionHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11460,35 +10701,27 @@ bool CompleteCollectionHeaderPubSubType::getKey( const CompleteCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteCollectionHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteCollectionHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11502,49 +10735,42 @@ void CompleteCollectionHeaderPubSubType::register_type_object_representation() MinimalCollectionHeaderPubSubType::MinimalCollectionHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalCollectionHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalCollectionHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalCollectionHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalCollectionHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalCollectionHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalCollectionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalCollectionHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalCollectionHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalCollectionHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalCollectionHeaderPubSubType::~MinimalCollectionHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalCollectionHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11559,16 +10785,12 @@ bool MinimalCollectionHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalCollectionHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11577,76 +10799,82 @@ bool MinimalCollectionHeaderPubSubType::deserialize( MinimalCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + 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 false; + } + + return true; +} + +uint32_t MinimalCollectionHeaderPubSubType::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; } - - return true; } -std::function MinimalCollectionHeaderPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalCollectionHeaderPubSubType::createData() +void* MinimalCollectionHeaderPubSubType::create_data() { return reinterpret_cast(new MinimalCollectionHeader()); } -void MinimalCollectionHeaderPubSubType::deleteData( +void MinimalCollectionHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalCollectionHeaderPubSubType::getKey( +bool MinimalCollectionHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalCollectionHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalCollectionHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11654,35 +10882,27 @@ bool MinimalCollectionHeaderPubSubType::getKey( const MinimalCollectionHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalCollectionHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalCollectionHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11696,49 +10916,42 @@ void MinimalCollectionHeaderPubSubType::register_type_object_representation() CompleteSequenceTypePubSubType::CompleteSequenceTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteSequenceType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteSequenceType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteSequenceType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteSequenceType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteSequenceType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteSequenceType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteSequenceType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteSequenceType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteSequenceType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteSequenceTypePubSubType::~CompleteSequenceTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteSequenceTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteSequenceType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11753,16 +10966,12 @@ bool CompleteSequenceTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteSequenceTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11771,18 +10980,14 @@ bool CompleteSequenceTypePubSubType::deserialize( CompleteSequenceType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11795,52 +11000,62 @@ bool CompleteSequenceTypePubSubType::deserialize( return true; } -std::function CompleteSequenceTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteSequenceTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteSequenceTypePubSubType::createData() + 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* CompleteSequenceTypePubSubType::create_data() { return reinterpret_cast(new CompleteSequenceType()); } -void CompleteSequenceTypePubSubType::deleteData( +void CompleteSequenceTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteSequenceTypePubSubType::getKey( +bool CompleteSequenceTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteSequenceType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteSequenceTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11848,35 +11063,27 @@ bool CompleteSequenceTypePubSubType::getKey( const CompleteSequenceType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteSequenceType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteSequenceType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11890,49 +11097,42 @@ void CompleteSequenceTypePubSubType::register_type_object_representation() MinimalSequenceTypePubSubType::MinimalSequenceTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalSequenceType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalSequenceType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalSequenceType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalSequenceType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalSequenceType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalSequenceType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalSequenceType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalSequenceType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalSequenceType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalSequenceTypePubSubType::~MinimalSequenceTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalSequenceTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalSequenceType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11947,16 +11147,12 @@ bool MinimalSequenceTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalSequenceTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11965,18 +11161,14 @@ bool MinimalSequenceTypePubSubType::deserialize( MinimalSequenceType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11989,52 +11181,62 @@ bool MinimalSequenceTypePubSubType::deserialize( return true; } -std::function MinimalSequenceTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalSequenceTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalSequenceTypePubSubType::createData() + 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* MinimalSequenceTypePubSubType::create_data() { return reinterpret_cast(new MinimalSequenceType()); } -void MinimalSequenceTypePubSubType::deleteData( +void MinimalSequenceTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalSequenceTypePubSubType::getKey( +bool MinimalSequenceTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalSequenceType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalSequenceTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12042,35 +11244,27 @@ bool MinimalSequenceTypePubSubType::getKey( const MinimalSequenceType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalSequenceType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalSequenceType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12084,49 +11278,42 @@ void MinimalSequenceTypePubSubType::register_type_object_representation() CommonArrayHeaderPubSubType::CommonArrayHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonArrayHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonArrayHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonArrayHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonArrayHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonArrayHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonArrayHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonArrayHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonArrayHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonArrayHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonArrayHeaderPubSubType::~CommonArrayHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonArrayHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonArrayHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12141,16 +11328,12 @@ bool CommonArrayHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonArrayHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12159,18 +11342,14 @@ bool CommonArrayHeaderPubSubType::deserialize( CommonArrayHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12183,52 +11362,62 @@ bool CommonArrayHeaderPubSubType::deserialize( return true; } -std::function CommonArrayHeaderPubSubType::getSerializedSizeProvider( +uint32_t CommonArrayHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonArrayHeaderPubSubType::createData() + 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* CommonArrayHeaderPubSubType::create_data() { return reinterpret_cast(new CommonArrayHeader()); } -void CommonArrayHeaderPubSubType::deleteData( +void CommonArrayHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonArrayHeaderPubSubType::getKey( +bool CommonArrayHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonArrayHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonArrayHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12236,35 +11425,27 @@ bool CommonArrayHeaderPubSubType::getKey( const CommonArrayHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonArrayHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonArrayHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12278,49 +11459,42 @@ void CommonArrayHeaderPubSubType::register_type_object_representation() CompleteArrayHeaderPubSubType::CompleteArrayHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteArrayHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteArrayHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteArrayHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteArrayHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteArrayHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteArrayHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteArrayHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteArrayHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteArrayHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteArrayHeaderPubSubType::~CompleteArrayHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteArrayHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteArrayHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12335,16 +11509,12 @@ bool CompleteArrayHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteArrayHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12353,18 +11523,14 @@ bool CompleteArrayHeaderPubSubType::deserialize( CompleteArrayHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12377,52 +11543,62 @@ bool CompleteArrayHeaderPubSubType::deserialize( return true; } -std::function CompleteArrayHeaderPubSubType::getSerializedSizeProvider( +uint32_t CompleteArrayHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteArrayHeaderPubSubType::createData() + 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* CompleteArrayHeaderPubSubType::create_data() { return reinterpret_cast(new CompleteArrayHeader()); } -void CompleteArrayHeaderPubSubType::deleteData( +void CompleteArrayHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteArrayHeaderPubSubType::getKey( +bool CompleteArrayHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteArrayHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteArrayHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12430,35 +11606,27 @@ bool CompleteArrayHeaderPubSubType::getKey( const CompleteArrayHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteArrayHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteArrayHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12472,49 +11640,42 @@ void CompleteArrayHeaderPubSubType::register_type_object_representation() MinimalArrayHeaderPubSubType::MinimalArrayHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalArrayHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalArrayHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalArrayHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalArrayHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalArrayHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalArrayHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalArrayHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalArrayHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalArrayHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalArrayHeaderPubSubType::~MinimalArrayHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalArrayHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalArrayHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12529,16 +11690,12 @@ bool MinimalArrayHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalArrayHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12547,18 +11704,14 @@ bool MinimalArrayHeaderPubSubType::deserialize( MinimalArrayHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12571,52 +11724,62 @@ bool MinimalArrayHeaderPubSubType::deserialize( return true; } -std::function MinimalArrayHeaderPubSubType::getSerializedSizeProvider( +uint32_t MinimalArrayHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalArrayHeaderPubSubType::createData() + 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* MinimalArrayHeaderPubSubType::create_data() { return reinterpret_cast(new MinimalArrayHeader()); } -void MinimalArrayHeaderPubSubType::deleteData( +void MinimalArrayHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalArrayHeaderPubSubType::getKey( +bool MinimalArrayHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalArrayHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalArrayHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12624,35 +11787,27 @@ bool MinimalArrayHeaderPubSubType::getKey( const MinimalArrayHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalArrayHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalArrayHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12666,49 +11821,42 @@ void MinimalArrayHeaderPubSubType::register_type_object_representation() CompleteArrayTypePubSubType::CompleteArrayTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteArrayType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteArrayType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteArrayType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteArrayType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteArrayType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteArrayType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteArrayType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteArrayType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteArrayType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteArrayTypePubSubType::~CompleteArrayTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteArrayTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteArrayType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12723,16 +11871,12 @@ bool CompleteArrayTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteArrayTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12741,18 +11885,14 @@ bool CompleteArrayTypePubSubType::deserialize( CompleteArrayType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12765,52 +11905,62 @@ bool CompleteArrayTypePubSubType::deserialize( return true; } -std::function CompleteArrayTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteArrayTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteArrayTypePubSubType::createData() + 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* CompleteArrayTypePubSubType::create_data() { return reinterpret_cast(new CompleteArrayType()); } -void CompleteArrayTypePubSubType::deleteData( +void CompleteArrayTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteArrayTypePubSubType::getKey( +bool CompleteArrayTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteArrayType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteArrayTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12818,35 +11968,27 @@ bool CompleteArrayTypePubSubType::getKey( const CompleteArrayType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteArrayType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteArrayType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12860,49 +12002,42 @@ void CompleteArrayTypePubSubType::register_type_object_representation() MinimalArrayTypePubSubType::MinimalArrayTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalArrayType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalArrayType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalArrayType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalArrayType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalArrayType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalArrayType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalArrayType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalArrayType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalArrayType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalArrayTypePubSubType::~MinimalArrayTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalArrayTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalArrayType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12917,16 +12052,12 @@ bool MinimalArrayTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalArrayTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12935,18 +12066,14 @@ bool MinimalArrayTypePubSubType::deserialize( MinimalArrayType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12959,52 +12086,62 @@ bool MinimalArrayTypePubSubType::deserialize( return true; } -std::function MinimalArrayTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalArrayTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalArrayTypePubSubType::createData() + 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* MinimalArrayTypePubSubType::create_data() { return reinterpret_cast(new MinimalArrayType()); } -void MinimalArrayTypePubSubType::deleteData( +void MinimalArrayTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalArrayTypePubSubType::getKey( +bool MinimalArrayTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalArrayType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalArrayTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13012,35 +12149,27 @@ bool MinimalArrayTypePubSubType::getKey( const MinimalArrayType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalArrayType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalArrayType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13054,49 +12183,42 @@ void MinimalArrayTypePubSubType::register_type_object_representation() CompleteMapTypePubSubType::CompleteMapTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteMapType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteMapType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteMapType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteMapType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteMapType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteMapType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteMapType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteMapType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteMapType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteMapTypePubSubType::~CompleteMapTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteMapTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteMapType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13111,16 +12233,12 @@ bool CompleteMapTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteMapTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13129,18 +12247,14 @@ bool CompleteMapTypePubSubType::deserialize( CompleteMapType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13153,52 +12267,62 @@ bool CompleteMapTypePubSubType::deserialize( return true; } -std::function CompleteMapTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteMapTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteMapTypePubSubType::createData() + 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* CompleteMapTypePubSubType::create_data() { return reinterpret_cast(new CompleteMapType()); } -void CompleteMapTypePubSubType::deleteData( +void CompleteMapTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteMapTypePubSubType::getKey( +bool CompleteMapTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteMapType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteMapTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13206,35 +12330,27 @@ bool CompleteMapTypePubSubType::getKey( const CompleteMapType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteMapType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteMapType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13248,49 +12364,42 @@ void CompleteMapTypePubSubType::register_type_object_representation() MinimalMapTypePubSubType::MinimalMapTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalMapType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalMapType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalMapType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalMapType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalMapType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalMapType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalMapType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalMapType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalMapType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalMapTypePubSubType::~MinimalMapTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalMapTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalMapType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13305,16 +12414,12 @@ bool MinimalMapTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalMapTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13323,18 +12428,14 @@ bool MinimalMapTypePubSubType::deserialize( MinimalMapType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13347,52 +12448,62 @@ bool MinimalMapTypePubSubType::deserialize( return true; } -std::function MinimalMapTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalMapTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalMapTypePubSubType::createData() + 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* MinimalMapTypePubSubType::create_data() { return reinterpret_cast(new MinimalMapType()); } -void MinimalMapTypePubSubType::deleteData( +void MinimalMapTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalMapTypePubSubType::getKey( +bool MinimalMapTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalMapType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalMapTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13400,35 +12511,27 @@ bool MinimalMapTypePubSubType::getKey( const MinimalMapType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalMapType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalMapType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13443,49 +12546,42 @@ void MinimalMapTypePubSubType::register_type_object_representation() CommonEnumeratedLiteralPubSubType::CommonEnumeratedLiteralPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonEnumeratedLiteral"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonEnumeratedLiteral::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonEnumeratedLiteral_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonEnumeratedLiteral"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonEnumeratedLiteral_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonEnumeratedLiteral_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonEnumeratedLiteral_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonEnumeratedLiteral_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonEnumeratedLiteral_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonEnumeratedLiteralPubSubType::~CommonEnumeratedLiteralPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonEnumeratedLiteralPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonEnumeratedLiteral* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13500,16 +12596,12 @@ bool CommonEnumeratedLiteralPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonEnumeratedLiteralPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13518,18 +12610,14 @@ bool CommonEnumeratedLiteralPubSubType::deserialize( CommonEnumeratedLiteral* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13542,52 +12630,62 @@ bool CommonEnumeratedLiteralPubSubType::deserialize( return true; } -std::function CommonEnumeratedLiteralPubSubType::getSerializedSizeProvider( +uint32_t CommonEnumeratedLiteralPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonEnumeratedLiteralPubSubType::createData() + 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* CommonEnumeratedLiteralPubSubType::create_data() { return reinterpret_cast(new CommonEnumeratedLiteral()); } -void CommonEnumeratedLiteralPubSubType::deleteData( +void CommonEnumeratedLiteralPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonEnumeratedLiteralPubSubType::getKey( +bool CommonEnumeratedLiteralPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonEnumeratedLiteral data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonEnumeratedLiteralPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13595,35 +12693,27 @@ bool CommonEnumeratedLiteralPubSubType::getKey( const CommonEnumeratedLiteral* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonEnumeratedLiteral_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonEnumeratedLiteral_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13637,49 +12727,42 @@ void CommonEnumeratedLiteralPubSubType::register_type_object_representation() CompleteEnumeratedLiteralPubSubType::CompleteEnumeratedLiteralPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteEnumeratedLiteral"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteEnumeratedLiteral::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteEnumeratedLiteral_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteEnumeratedLiteral"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteEnumeratedLiteral_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteEnumeratedLiteral_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteEnumeratedLiteral_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteEnumeratedLiteral_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteEnumeratedLiteral_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteEnumeratedLiteralPubSubType::~CompleteEnumeratedLiteralPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteEnumeratedLiteralPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteEnumeratedLiteral* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13694,16 +12777,12 @@ bool CompleteEnumeratedLiteralPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteEnumeratedLiteralPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13712,18 +12791,14 @@ bool CompleteEnumeratedLiteralPubSubType::deserialize( CompleteEnumeratedLiteral* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13736,52 +12811,62 @@ bool CompleteEnumeratedLiteralPubSubType::deserialize( return true; } -std::function CompleteEnumeratedLiteralPubSubType::getSerializedSizeProvider( +uint32_t CompleteEnumeratedLiteralPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteEnumeratedLiteralPubSubType::createData() + 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* CompleteEnumeratedLiteralPubSubType::create_data() { return reinterpret_cast(new CompleteEnumeratedLiteral()); } -void CompleteEnumeratedLiteralPubSubType::deleteData( +void CompleteEnumeratedLiteralPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteEnumeratedLiteralPubSubType::getKey( +bool CompleteEnumeratedLiteralPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteEnumeratedLiteral data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteEnumeratedLiteralPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13789,35 +12874,27 @@ bool CompleteEnumeratedLiteralPubSubType::getKey( const CompleteEnumeratedLiteral* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteEnumeratedLiteral_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteEnumeratedLiteral_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13832,49 +12909,42 @@ void CompleteEnumeratedLiteralPubSubType::register_type_object_representation() MinimalEnumeratedLiteralPubSubType::MinimalEnumeratedLiteralPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalEnumeratedLiteral"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalEnumeratedLiteral::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalEnumeratedLiteral_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalEnumeratedLiteral"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalEnumeratedLiteral_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalEnumeratedLiteral_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalEnumeratedLiteral_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalEnumeratedLiteral_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalEnumeratedLiteral_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalEnumeratedLiteralPubSubType::~MinimalEnumeratedLiteralPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalEnumeratedLiteralPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalEnumeratedLiteral* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13889,16 +12959,12 @@ bool MinimalEnumeratedLiteralPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalEnumeratedLiteralPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13907,18 +12973,14 @@ bool MinimalEnumeratedLiteralPubSubType::deserialize( MinimalEnumeratedLiteral* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13931,52 +12993,62 @@ bool MinimalEnumeratedLiteralPubSubType::deserialize( return true; } -std::function MinimalEnumeratedLiteralPubSubType::getSerializedSizeProvider( +uint32_t MinimalEnumeratedLiteralPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalEnumeratedLiteralPubSubType::createData() + 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* MinimalEnumeratedLiteralPubSubType::create_data() { return reinterpret_cast(new MinimalEnumeratedLiteral()); } -void MinimalEnumeratedLiteralPubSubType::deleteData( +void MinimalEnumeratedLiteralPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalEnumeratedLiteralPubSubType::getKey( +bool MinimalEnumeratedLiteralPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalEnumeratedLiteral data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalEnumeratedLiteralPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13984,35 +13056,27 @@ bool MinimalEnumeratedLiteralPubSubType::getKey( const MinimalEnumeratedLiteral* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalEnumeratedLiteral_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalEnumeratedLiteral_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14027,49 +13091,42 @@ void MinimalEnumeratedLiteralPubSubType::register_type_object_representation() CommonEnumeratedHeaderPubSubType::CommonEnumeratedHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonEnumeratedHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonEnumeratedHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonEnumeratedHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonEnumeratedHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonEnumeratedHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonEnumeratedHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonEnumeratedHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonEnumeratedHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonEnumeratedHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonEnumeratedHeaderPubSubType::~CommonEnumeratedHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonEnumeratedHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonEnumeratedHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14084,16 +13141,12 @@ bool CommonEnumeratedHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonEnumeratedHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14102,18 +13155,14 @@ bool CommonEnumeratedHeaderPubSubType::deserialize( CommonEnumeratedHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14126,52 +13175,62 @@ bool CommonEnumeratedHeaderPubSubType::deserialize( return true; } -std::function CommonEnumeratedHeaderPubSubType::getSerializedSizeProvider( +uint32_t CommonEnumeratedHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonEnumeratedHeaderPubSubType::createData() + 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* CommonEnumeratedHeaderPubSubType::create_data() { return reinterpret_cast(new CommonEnumeratedHeader()); } -void CommonEnumeratedHeaderPubSubType::deleteData( +void CommonEnumeratedHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonEnumeratedHeaderPubSubType::getKey( +bool CommonEnumeratedHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonEnumeratedHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonEnumeratedHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14179,35 +13238,27 @@ bool CommonEnumeratedHeaderPubSubType::getKey( const CommonEnumeratedHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonEnumeratedHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonEnumeratedHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14221,49 +13272,42 @@ void CommonEnumeratedHeaderPubSubType::register_type_object_representation() CompleteEnumeratedHeaderPubSubType::CompleteEnumeratedHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteEnumeratedHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteEnumeratedHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteEnumeratedHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteEnumeratedHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteEnumeratedHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteEnumeratedHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteEnumeratedHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteEnumeratedHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteEnumeratedHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteEnumeratedHeaderPubSubType::~CompleteEnumeratedHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteEnumeratedHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteEnumeratedHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14278,16 +13322,12 @@ bool CompleteEnumeratedHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteEnumeratedHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14296,18 +13336,14 @@ bool CompleteEnumeratedHeaderPubSubType::deserialize( CompleteEnumeratedHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14320,52 +13356,62 @@ bool CompleteEnumeratedHeaderPubSubType::deserialize( return true; } -std::function CompleteEnumeratedHeaderPubSubType::getSerializedSizeProvider( +uint32_t CompleteEnumeratedHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteEnumeratedHeaderPubSubType::createData() + 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* CompleteEnumeratedHeaderPubSubType::create_data() { return reinterpret_cast(new CompleteEnumeratedHeader()); } -void CompleteEnumeratedHeaderPubSubType::deleteData( +void CompleteEnumeratedHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteEnumeratedHeaderPubSubType::getKey( +bool CompleteEnumeratedHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteEnumeratedHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteEnumeratedHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14373,35 +13419,27 @@ bool CompleteEnumeratedHeaderPubSubType::getKey( const CompleteEnumeratedHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteEnumeratedHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteEnumeratedHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14415,49 +13453,42 @@ void CompleteEnumeratedHeaderPubSubType::register_type_object_representation() MinimalEnumeratedHeaderPubSubType::MinimalEnumeratedHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalEnumeratedHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalEnumeratedHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalEnumeratedHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalEnumeratedHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalEnumeratedHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalEnumeratedHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalEnumeratedHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalEnumeratedHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalEnumeratedHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalEnumeratedHeaderPubSubType::~MinimalEnumeratedHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalEnumeratedHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalEnumeratedHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14472,16 +13503,12 @@ bool MinimalEnumeratedHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalEnumeratedHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14490,18 +13517,14 @@ bool MinimalEnumeratedHeaderPubSubType::deserialize( MinimalEnumeratedHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14514,52 +13537,62 @@ bool MinimalEnumeratedHeaderPubSubType::deserialize( return true; } -std::function MinimalEnumeratedHeaderPubSubType::getSerializedSizeProvider( +uint32_t MinimalEnumeratedHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalEnumeratedHeaderPubSubType::createData() + 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* MinimalEnumeratedHeaderPubSubType::create_data() { return reinterpret_cast(new MinimalEnumeratedHeader()); } -void MinimalEnumeratedHeaderPubSubType::deleteData( +void MinimalEnumeratedHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalEnumeratedHeaderPubSubType::getKey( +bool MinimalEnumeratedHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalEnumeratedHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalEnumeratedHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14567,35 +13600,27 @@ bool MinimalEnumeratedHeaderPubSubType::getKey( const MinimalEnumeratedHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalEnumeratedHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalEnumeratedHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14609,49 +13634,42 @@ void MinimalEnumeratedHeaderPubSubType::register_type_object_representation() CompleteEnumeratedTypePubSubType::CompleteEnumeratedTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteEnumeratedType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteEnumeratedType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteEnumeratedType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteEnumeratedType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteEnumeratedType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteEnumeratedType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteEnumeratedType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteEnumeratedType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteEnumeratedType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteEnumeratedTypePubSubType::~CompleteEnumeratedTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteEnumeratedTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteEnumeratedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14666,16 +13684,12 @@ bool CompleteEnumeratedTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteEnumeratedTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14684,18 +13698,14 @@ bool CompleteEnumeratedTypePubSubType::deserialize( CompleteEnumeratedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14708,52 +13718,62 @@ bool CompleteEnumeratedTypePubSubType::deserialize( return true; } -std::function CompleteEnumeratedTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteEnumeratedTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteEnumeratedTypePubSubType::createData() + 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* CompleteEnumeratedTypePubSubType::create_data() { return reinterpret_cast(new CompleteEnumeratedType()); } -void CompleteEnumeratedTypePubSubType::deleteData( +void CompleteEnumeratedTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteEnumeratedTypePubSubType::getKey( +bool CompleteEnumeratedTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteEnumeratedType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteEnumeratedTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14761,35 +13781,27 @@ bool CompleteEnumeratedTypePubSubType::getKey( const CompleteEnumeratedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteEnumeratedType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteEnumeratedType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14803,49 +13815,42 @@ void CompleteEnumeratedTypePubSubType::register_type_object_representation() MinimalEnumeratedTypePubSubType::MinimalEnumeratedTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalEnumeratedType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalEnumeratedType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalEnumeratedType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalEnumeratedType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalEnumeratedType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalEnumeratedType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalEnumeratedType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalEnumeratedType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalEnumeratedType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalEnumeratedTypePubSubType::~MinimalEnumeratedTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalEnumeratedTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalEnumeratedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14860,16 +13865,12 @@ bool MinimalEnumeratedTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalEnumeratedTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14878,18 +13879,14 @@ bool MinimalEnumeratedTypePubSubType::deserialize( MinimalEnumeratedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14902,52 +13899,62 @@ bool MinimalEnumeratedTypePubSubType::deserialize( return true; } -std::function MinimalEnumeratedTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalEnumeratedTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalEnumeratedTypePubSubType::createData() + 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* MinimalEnumeratedTypePubSubType::create_data() { return reinterpret_cast(new MinimalEnumeratedType()); } -void MinimalEnumeratedTypePubSubType::deleteData( +void MinimalEnumeratedTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalEnumeratedTypePubSubType::getKey( +bool MinimalEnumeratedTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalEnumeratedType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalEnumeratedTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14955,35 +13962,27 @@ bool MinimalEnumeratedTypePubSubType::getKey( const MinimalEnumeratedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalEnumeratedType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalEnumeratedType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14997,49 +13996,42 @@ void MinimalEnumeratedTypePubSubType::register_type_object_representation() CommonBitflagPubSubType::CommonBitflagPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonBitflag"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonBitflag::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonBitflag_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonBitflag"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonBitflag_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonBitflag_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonBitflag_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonBitflag_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonBitflag_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonBitflagPubSubType::~CommonBitflagPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonBitflagPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonBitflag* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15054,16 +14046,12 @@ bool CommonBitflagPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonBitflagPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15072,18 +14060,14 @@ bool CommonBitflagPubSubType::deserialize( CommonBitflag* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15096,52 +14080,62 @@ bool CommonBitflagPubSubType::deserialize( return true; } -std::function CommonBitflagPubSubType::getSerializedSizeProvider( +uint32_t CommonBitflagPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonBitflagPubSubType::createData() + 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* CommonBitflagPubSubType::create_data() { return reinterpret_cast(new CommonBitflag()); } -void CommonBitflagPubSubType::deleteData( +void CommonBitflagPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonBitflagPubSubType::getKey( +bool CommonBitflagPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonBitflag data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonBitflagPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15149,35 +14143,27 @@ bool CommonBitflagPubSubType::getKey( const CommonBitflag* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonBitflag_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonBitflag_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15191,49 +14177,42 @@ void CommonBitflagPubSubType::register_type_object_representation() CompleteBitflagPubSubType::CompleteBitflagPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteBitflag"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteBitflag::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteBitflag_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteBitflag"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteBitflag_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteBitflag_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteBitflag_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteBitflag_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteBitflag_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteBitflagPubSubType::~CompleteBitflagPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteBitflagPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteBitflag* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15248,16 +14227,12 @@ bool CompleteBitflagPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteBitflagPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15266,18 +14241,14 @@ bool CompleteBitflagPubSubType::deserialize( CompleteBitflag* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15290,52 +14261,62 @@ bool CompleteBitflagPubSubType::deserialize( return true; } -std::function CompleteBitflagPubSubType::getSerializedSizeProvider( +uint32_t CompleteBitflagPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteBitflagPubSubType::createData() + 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* CompleteBitflagPubSubType::create_data() { return reinterpret_cast(new CompleteBitflag()); } -void CompleteBitflagPubSubType::deleteData( +void CompleteBitflagPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteBitflagPubSubType::getKey( +bool CompleteBitflagPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteBitflag data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteBitflagPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15343,35 +14324,27 @@ bool CompleteBitflagPubSubType::getKey( const CompleteBitflag* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteBitflag_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteBitflag_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15386,49 +14359,42 @@ void CompleteBitflagPubSubType::register_type_object_representation() MinimalBitflagPubSubType::MinimalBitflagPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalBitflag"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalBitflag::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalBitflag_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalBitflag"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalBitflag_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalBitflag_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalBitflag_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalBitflag_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalBitflag_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalBitflagPubSubType::~MinimalBitflagPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalBitflagPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalBitflag* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15443,16 +14409,12 @@ bool MinimalBitflagPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalBitflagPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15461,18 +14423,14 @@ bool MinimalBitflagPubSubType::deserialize( MinimalBitflag* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15485,52 +14443,62 @@ bool MinimalBitflagPubSubType::deserialize( return true; } -std::function MinimalBitflagPubSubType::getSerializedSizeProvider( +uint32_t MinimalBitflagPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalBitflagPubSubType::createData() + 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* MinimalBitflagPubSubType::create_data() { return reinterpret_cast(new MinimalBitflag()); } -void MinimalBitflagPubSubType::deleteData( +void MinimalBitflagPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalBitflagPubSubType::getKey( +bool MinimalBitflagPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalBitflag data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalBitflagPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15538,35 +14506,27 @@ bool MinimalBitflagPubSubType::getKey( const MinimalBitflag* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalBitflag_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalBitflag_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15581,49 +14541,42 @@ void MinimalBitflagPubSubType::register_type_object_representation() CommonBitmaskHeaderPubSubType::CommonBitmaskHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonBitmaskHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonBitmaskHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonBitmaskHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonBitmaskHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonBitmaskHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonBitmaskHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonBitmaskHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonBitmaskHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonBitmaskHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonBitmaskHeaderPubSubType::~CommonBitmaskHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonBitmaskHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonBitmaskHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15638,16 +14591,12 @@ bool CommonBitmaskHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonBitmaskHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15656,18 +14605,14 @@ bool CommonBitmaskHeaderPubSubType::deserialize( CommonBitmaskHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15680,52 +14625,62 @@ bool CommonBitmaskHeaderPubSubType::deserialize( return true; } -std::function CommonBitmaskHeaderPubSubType::getSerializedSizeProvider( +uint32_t CommonBitmaskHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonBitmaskHeaderPubSubType::createData() + 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* CommonBitmaskHeaderPubSubType::create_data() { return reinterpret_cast(new CommonBitmaskHeader()); } -void CommonBitmaskHeaderPubSubType::deleteData( +void CommonBitmaskHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonBitmaskHeaderPubSubType::getKey( +bool CommonBitmaskHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonBitmaskHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonBitmaskHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15733,35 +14688,27 @@ bool CommonBitmaskHeaderPubSubType::getKey( const CommonBitmaskHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonBitmaskHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonBitmaskHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15777,49 +14724,42 @@ void CommonBitmaskHeaderPubSubType::register_type_object_representation() CompleteBitmaskTypePubSubType::CompleteBitmaskTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteBitmaskType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteBitmaskType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteBitmaskType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteBitmaskType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteBitmaskType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteBitmaskType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteBitmaskType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteBitmaskType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteBitmaskType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteBitmaskTypePubSubType::~CompleteBitmaskTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteBitmaskTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteBitmaskType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15834,16 +14774,12 @@ bool CompleteBitmaskTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteBitmaskTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15852,18 +14788,14 @@ bool CompleteBitmaskTypePubSubType::deserialize( CompleteBitmaskType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15876,52 +14808,62 @@ bool CompleteBitmaskTypePubSubType::deserialize( return true; } -std::function CompleteBitmaskTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteBitmaskTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteBitmaskTypePubSubType::createData() + 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* CompleteBitmaskTypePubSubType::create_data() { return reinterpret_cast(new CompleteBitmaskType()); } -void CompleteBitmaskTypePubSubType::deleteData( +void CompleteBitmaskTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteBitmaskTypePubSubType::getKey( +bool CompleteBitmaskTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteBitmaskType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteBitmaskTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15929,35 +14871,27 @@ bool CompleteBitmaskTypePubSubType::getKey( const CompleteBitmaskType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteBitmaskType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteBitmaskType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15971,49 +14905,42 @@ void CompleteBitmaskTypePubSubType::register_type_object_representation() MinimalBitmaskTypePubSubType::MinimalBitmaskTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalBitmaskType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalBitmaskType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalBitmaskType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalBitmaskType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalBitmaskType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalBitmaskType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalBitmaskType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalBitmaskType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalBitmaskType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalBitmaskTypePubSubType::~MinimalBitmaskTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalBitmaskTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalBitmaskType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16028,16 +14955,12 @@ bool MinimalBitmaskTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalBitmaskTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16046,18 +14969,14 @@ bool MinimalBitmaskTypePubSubType::deserialize( MinimalBitmaskType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16070,52 +14989,62 @@ bool MinimalBitmaskTypePubSubType::deserialize( return true; } -std::function MinimalBitmaskTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalBitmaskTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalBitmaskTypePubSubType::createData() + 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* MinimalBitmaskTypePubSubType::create_data() { return reinterpret_cast(new MinimalBitmaskType()); } -void MinimalBitmaskTypePubSubType::deleteData( +void MinimalBitmaskTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalBitmaskTypePubSubType::getKey( +bool MinimalBitmaskTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalBitmaskType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalBitmaskTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16123,35 +15052,27 @@ bool MinimalBitmaskTypePubSubType::getKey( const MinimalBitmaskType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalBitmaskType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalBitmaskType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16165,49 +15086,42 @@ void MinimalBitmaskTypePubSubType::register_type_object_representation() CommonBitfieldPubSubType::CommonBitfieldPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CommonBitfield"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CommonBitfield::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CommonBitfield_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CommonBitfield"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CommonBitfield_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CommonBitfield_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonBitfield_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CommonBitfield_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CommonBitfield_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CommonBitfieldPubSubType::~CommonBitfieldPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CommonBitfieldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CommonBitfield* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16222,16 +15136,12 @@ bool CommonBitfieldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CommonBitfieldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16240,18 +15150,14 @@ bool CommonBitfieldPubSubType::deserialize( CommonBitfield* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16264,52 +15170,62 @@ bool CommonBitfieldPubSubType::deserialize( return true; } -std::function CommonBitfieldPubSubType::getSerializedSizeProvider( +uint32_t CommonBitfieldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CommonBitfieldPubSubType::createData() + 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* CommonBitfieldPubSubType::create_data() { return reinterpret_cast(new CommonBitfield()); } -void CommonBitfieldPubSubType::deleteData( +void CommonBitfieldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CommonBitfieldPubSubType::getKey( +bool CommonBitfieldPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CommonBitfield data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CommonBitfieldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16317,35 +15233,27 @@ bool CommonBitfieldPubSubType::getKey( const CommonBitfield* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CommonBitfield_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CommonBitfield_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16359,49 +15267,42 @@ void CommonBitfieldPubSubType::register_type_object_representation() CompleteBitfieldPubSubType::CompleteBitfieldPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteBitfield"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteBitfield::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteBitfield_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteBitfield"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteBitfield_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteBitfield_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteBitfield_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteBitfield_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteBitfield_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteBitfieldPubSubType::~CompleteBitfieldPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteBitfieldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteBitfield* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16416,16 +15317,12 @@ bool CompleteBitfieldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteBitfieldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16434,18 +15331,14 @@ bool CompleteBitfieldPubSubType::deserialize( CompleteBitfield* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16454,56 +15347,66 @@ bool CompleteBitfieldPubSubType::deserialize( { return false; } - - return true; + + return true; +} + +uint32_t CompleteBitfieldPubSubType::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; + } } -std::function CompleteBitfieldPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteBitfieldPubSubType::createData() +void* CompleteBitfieldPubSubType::create_data() { return reinterpret_cast(new CompleteBitfield()); } -void CompleteBitfieldPubSubType::deleteData( +void CompleteBitfieldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteBitfieldPubSubType::getKey( +bool CompleteBitfieldPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteBitfield data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteBitfieldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16511,35 +15414,27 @@ bool CompleteBitfieldPubSubType::getKey( const CompleteBitfield* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteBitfield_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteBitfield_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16554,49 +15449,42 @@ void CompleteBitfieldPubSubType::register_type_object_representation() MinimalBitfieldPubSubType::MinimalBitfieldPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalBitfield"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalBitfield::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalBitfield_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalBitfield"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalBitfield_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalBitfield_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalBitfield_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalBitfield_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalBitfield_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalBitfieldPubSubType::~MinimalBitfieldPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalBitfieldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalBitfield* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16611,16 +15499,12 @@ bool MinimalBitfieldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalBitfieldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16629,18 +15513,14 @@ bool MinimalBitfieldPubSubType::deserialize( MinimalBitfield* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16653,52 +15533,62 @@ bool MinimalBitfieldPubSubType::deserialize( return true; } -std::function MinimalBitfieldPubSubType::getSerializedSizeProvider( +uint32_t MinimalBitfieldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalBitfieldPubSubType::createData() + 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* MinimalBitfieldPubSubType::create_data() { return reinterpret_cast(new MinimalBitfield()); } -void MinimalBitfieldPubSubType::deleteData( +void MinimalBitfieldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalBitfieldPubSubType::getKey( +bool MinimalBitfieldPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalBitfield data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalBitfieldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16706,35 +15596,27 @@ bool MinimalBitfieldPubSubType::getKey( const MinimalBitfield* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalBitfield_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalBitfield_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16749,49 +15631,42 @@ void MinimalBitfieldPubSubType::register_type_object_representation() CompleteBitsetHeaderPubSubType::CompleteBitsetHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteBitsetHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteBitsetHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteBitsetHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteBitsetHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteBitsetHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteBitsetHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteBitsetHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteBitsetHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteBitsetHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteBitsetHeaderPubSubType::~CompleteBitsetHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteBitsetHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteBitsetHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16806,16 +15681,12 @@ bool CompleteBitsetHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteBitsetHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16824,18 +15695,14 @@ bool CompleteBitsetHeaderPubSubType::deserialize( CompleteBitsetHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16848,52 +15715,62 @@ bool CompleteBitsetHeaderPubSubType::deserialize( return true; } -std::function CompleteBitsetHeaderPubSubType::getSerializedSizeProvider( +uint32_t CompleteBitsetHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteBitsetHeaderPubSubType::createData() + 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* CompleteBitsetHeaderPubSubType::create_data() { return reinterpret_cast(new CompleteBitsetHeader()); } -void CompleteBitsetHeaderPubSubType::deleteData( +void CompleteBitsetHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteBitsetHeaderPubSubType::getKey( +bool CompleteBitsetHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteBitsetHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteBitsetHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16901,35 +15778,27 @@ bool CompleteBitsetHeaderPubSubType::getKey( const CompleteBitsetHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteBitsetHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteBitsetHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16943,49 +15812,42 @@ void CompleteBitsetHeaderPubSubType::register_type_object_representation() MinimalBitsetHeaderPubSubType::MinimalBitsetHeaderPubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalBitsetHeader"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalBitsetHeader::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalBitsetHeader_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalBitsetHeader"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalBitsetHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalBitsetHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalBitsetHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalBitsetHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalBitsetHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalBitsetHeaderPubSubType::~MinimalBitsetHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalBitsetHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalBitsetHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17000,16 +15862,12 @@ bool MinimalBitsetHeaderPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalBitsetHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17018,18 +15876,14 @@ bool MinimalBitsetHeaderPubSubType::deserialize( MinimalBitsetHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17042,52 +15896,62 @@ bool MinimalBitsetHeaderPubSubType::deserialize( return true; } -std::function MinimalBitsetHeaderPubSubType::getSerializedSizeProvider( +uint32_t MinimalBitsetHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalBitsetHeaderPubSubType::createData() + 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* MinimalBitsetHeaderPubSubType::create_data() { return reinterpret_cast(new MinimalBitsetHeader()); } -void MinimalBitsetHeaderPubSubType::deleteData( +void MinimalBitsetHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalBitsetHeaderPubSubType::getKey( +bool MinimalBitsetHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalBitsetHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalBitsetHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17095,35 +15959,27 @@ bool MinimalBitsetHeaderPubSubType::getKey( const MinimalBitsetHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalBitsetHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalBitsetHeader_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17137,49 +15993,42 @@ void MinimalBitsetHeaderPubSubType::register_type_object_representation() CompleteBitsetTypePubSubType::CompleteBitsetTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteBitsetType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteBitsetType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteBitsetType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteBitsetType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteBitsetType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteBitsetType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteBitsetType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteBitsetType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteBitsetType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteBitsetTypePubSubType::~CompleteBitsetTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteBitsetTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteBitsetType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17194,16 +16043,12 @@ bool CompleteBitsetTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteBitsetTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17212,18 +16057,14 @@ bool CompleteBitsetTypePubSubType::deserialize( CompleteBitsetType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17236,52 +16077,62 @@ bool CompleteBitsetTypePubSubType::deserialize( return true; } -std::function CompleteBitsetTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteBitsetTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteBitsetTypePubSubType::createData() + 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* CompleteBitsetTypePubSubType::create_data() { return reinterpret_cast(new CompleteBitsetType()); } -void CompleteBitsetTypePubSubType::deleteData( +void CompleteBitsetTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteBitsetTypePubSubType::getKey( +bool CompleteBitsetTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteBitsetType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteBitsetTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17289,35 +16140,27 @@ bool CompleteBitsetTypePubSubType::getKey( const CompleteBitsetType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteBitsetType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteBitsetType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17331,49 +16174,42 @@ void CompleteBitsetTypePubSubType::register_type_object_representation() MinimalBitsetTypePubSubType::MinimalBitsetTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalBitsetType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalBitsetType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalBitsetType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalBitsetType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalBitsetType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalBitsetType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalBitsetType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalBitsetType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalBitsetType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalBitsetTypePubSubType::~MinimalBitsetTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalBitsetTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalBitsetType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17388,16 +16224,12 @@ bool MinimalBitsetTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalBitsetTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17406,18 +16238,14 @@ bool MinimalBitsetTypePubSubType::deserialize( MinimalBitsetType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17430,52 +16258,62 @@ bool MinimalBitsetTypePubSubType::deserialize( return true; } -std::function MinimalBitsetTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalBitsetTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalBitsetTypePubSubType::createData() + 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* MinimalBitsetTypePubSubType::create_data() { return reinterpret_cast(new MinimalBitsetType()); } -void MinimalBitsetTypePubSubType::deleteData( +void MinimalBitsetTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalBitsetTypePubSubType::getKey( +bool MinimalBitsetTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalBitsetType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalBitsetTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17483,35 +16321,27 @@ bool MinimalBitsetTypePubSubType::getKey( const MinimalBitsetType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalBitsetType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalBitsetType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17525,49 +16355,42 @@ void MinimalBitsetTypePubSubType::register_type_object_representation() CompleteExtendedTypePubSubType::CompleteExtendedTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::CompleteExtendedType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteExtendedType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_CompleteExtendedType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::CompleteExtendedType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_CompleteExtendedType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_CompleteExtendedType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteExtendedType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_CompleteExtendedType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_CompleteExtendedType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CompleteExtendedTypePubSubType::~CompleteExtendedTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CompleteExtendedTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CompleteExtendedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17582,16 +16405,12 @@ bool CompleteExtendedTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CompleteExtendedTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17600,18 +16419,14 @@ bool CompleteExtendedTypePubSubType::deserialize( CompleteExtendedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17624,52 +16439,62 @@ bool CompleteExtendedTypePubSubType::deserialize( return true; } -std::function CompleteExtendedTypePubSubType::getSerializedSizeProvider( +uint32_t CompleteExtendedTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CompleteExtendedTypePubSubType::createData() + 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* CompleteExtendedTypePubSubType::create_data() { return reinterpret_cast(new CompleteExtendedType()); } -void CompleteExtendedTypePubSubType::deleteData( +void CompleteExtendedTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CompleteExtendedTypePubSubType::getKey( +bool CompleteExtendedTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CompleteExtendedType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CompleteExtendedTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17677,35 +16502,27 @@ bool CompleteExtendedTypePubSubType::getKey( const CompleteExtendedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_CompleteExtendedType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_CompleteExtendedType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17720,49 +16537,42 @@ void CompleteExtendedTypePubSubType::register_type_object_representation() MinimalExtendedTypePubSubType::MinimalExtendedTypePubSubType() { - setName("eprosima::fastdds::dds::xtypes::MinimalExtendedType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MinimalExtendedType::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_MinimalExtendedType_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::MinimalExtendedType"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_MinimalExtendedType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_MinimalExtendedType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalExtendedType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_MinimalExtendedType_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_MinimalExtendedType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MinimalExtendedTypePubSubType::~MinimalExtendedTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MinimalExtendedTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MinimalExtendedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17777,16 +16587,12 @@ bool MinimalExtendedTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MinimalExtendedTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17795,18 +16601,14 @@ bool MinimalExtendedTypePubSubType::deserialize( MinimalExtendedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17819,52 +16621,62 @@ bool MinimalExtendedTypePubSubType::deserialize( return true; } -std::function MinimalExtendedTypePubSubType::getSerializedSizeProvider( +uint32_t MinimalExtendedTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MinimalExtendedTypePubSubType::createData() + 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* MinimalExtendedTypePubSubType::create_data() { return reinterpret_cast(new MinimalExtendedType()); } -void MinimalExtendedTypePubSubType::deleteData( +void MinimalExtendedTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MinimalExtendedTypePubSubType::getKey( +bool MinimalExtendedTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MinimalExtendedType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MinimalExtendedTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17872,35 +16684,27 @@ bool MinimalExtendedTypePubSubType::getKey( const MinimalExtendedType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_MinimalExtendedType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_MinimalExtendedType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17918,49 +16722,42 @@ void MinimalExtendedTypePubSubType::register_type_object_representation() TypeIdentifierTypeObjectPairPubSubType::TypeIdentifierTypeObjectPairPubSubType() { - setName("eprosima::fastdds::dds::xtypes::TypeIdentifierTypeObjectPair"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeIdentifierTypeObjectPair::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_TypeIdentifierTypeObjectPair_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::TypeIdentifierTypeObjectPair"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_TypeIdentifierTypeObjectPair_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_TypeIdentifierTypeObjectPair_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_TypeIdentifierTypeObjectPair_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_TypeIdentifierTypeObjectPair_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_TypeIdentifierTypeObjectPair_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeIdentifierTypeObjectPairPubSubType::~TypeIdentifierTypeObjectPairPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeIdentifierTypeObjectPairPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeIdentifierTypeObjectPair* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17975,16 +16772,12 @@ bool TypeIdentifierTypeObjectPairPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeIdentifierTypeObjectPairPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17993,18 +16786,14 @@ bool TypeIdentifierTypeObjectPairPubSubType::deserialize( TypeIdentifierTypeObjectPair* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18017,52 +16806,62 @@ bool TypeIdentifierTypeObjectPairPubSubType::deserialize( return true; } -std::function TypeIdentifierTypeObjectPairPubSubType::getSerializedSizeProvider( +uint32_t TypeIdentifierTypeObjectPairPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* TypeIdentifierTypeObjectPairPubSubType::createData() + 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* TypeIdentifierTypeObjectPairPubSubType::create_data() { return reinterpret_cast(new TypeIdentifierTypeObjectPair()); } -void TypeIdentifierTypeObjectPairPubSubType::deleteData( +void TypeIdentifierTypeObjectPairPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool TypeIdentifierTypeObjectPairPubSubType::getKey( +bool TypeIdentifierTypeObjectPairPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + TypeIdentifierTypeObjectPair data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool TypeIdentifierTypeObjectPairPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18070,35 +16869,27 @@ bool TypeIdentifierTypeObjectPairPubSubType::getKey( const TypeIdentifierTypeObjectPair* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_TypeIdentifierTypeObjectPair_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_TypeIdentifierTypeObjectPair_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18113,49 +16904,42 @@ void TypeIdentifierTypeObjectPairPubSubType::register_type_object_representation TypeIdentifierPairPubSubType::TypeIdentifierPairPubSubType() { - setName("eprosima::fastdds::dds::xtypes::TypeIdentifierPair"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeIdentifierPair::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_TypeIdentifierPair_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::TypeIdentifierPair"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_TypeIdentifierPair_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_TypeIdentifierPair_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_TypeIdentifierPair_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_TypeIdentifierPair_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_TypeIdentifierPair_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeIdentifierPairPubSubType::~TypeIdentifierPairPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeIdentifierPairPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeIdentifierPair* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18170,16 +16954,12 @@ bool TypeIdentifierPairPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeIdentifierPairPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18188,18 +16968,14 @@ bool TypeIdentifierPairPubSubType::deserialize( TypeIdentifierPair* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18212,52 +16988,62 @@ bool TypeIdentifierPairPubSubType::deserialize( return true; } -std::function TypeIdentifierPairPubSubType::getSerializedSizeProvider( +uint32_t TypeIdentifierPairPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* TypeIdentifierPairPubSubType::createData() + 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* TypeIdentifierPairPubSubType::create_data() { return reinterpret_cast(new TypeIdentifierPair()); } -void TypeIdentifierPairPubSubType::deleteData( +void TypeIdentifierPairPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool TypeIdentifierPairPubSubType::getKey( +bool TypeIdentifierPairPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + TypeIdentifierPair data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool TypeIdentifierPairPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18265,35 +17051,27 @@ bool TypeIdentifierPairPubSubType::getKey( const TypeIdentifierPair* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_TypeIdentifierPair_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_TypeIdentifierPair_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18308,49 +17086,42 @@ void TypeIdentifierPairPubSubType::register_type_object_representation() TypeIdentfierWithSizePubSubType::TypeIdentfierWithSizePubSubType() { - setName("eprosima::fastdds::dds::xtypes::TypeIdentfierWithSize"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeIdentfierWithSize::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_TypeIdentfierWithSize_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::TypeIdentfierWithSize"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_TypeIdentfierWithSize_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_TypeIdentfierWithSize_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_TypeIdentfierWithSize_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_TypeIdentfierWithSize_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_TypeIdentfierWithSize_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeIdentfierWithSizePubSubType::~TypeIdentfierWithSizePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeIdentfierWithSizePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeIdentfierWithSize* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18365,16 +17136,12 @@ bool TypeIdentfierWithSizePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeIdentfierWithSizePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18383,18 +17150,14 @@ bool TypeIdentfierWithSizePubSubType::deserialize( TypeIdentfierWithSize* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18407,52 +17170,62 @@ bool TypeIdentfierWithSizePubSubType::deserialize( return true; } -std::function TypeIdentfierWithSizePubSubType::getSerializedSizeProvider( +uint32_t TypeIdentfierWithSizePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* TypeIdentfierWithSizePubSubType::createData() + 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* TypeIdentfierWithSizePubSubType::create_data() { return reinterpret_cast(new TypeIdentfierWithSize()); } -void TypeIdentfierWithSizePubSubType::deleteData( +void TypeIdentfierWithSizePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool TypeIdentfierWithSizePubSubType::getKey( +bool TypeIdentfierWithSizePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + TypeIdentfierWithSize data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool TypeIdentfierWithSizePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18460,35 +17233,27 @@ bool TypeIdentfierWithSizePubSubType::getKey( const TypeIdentfierWithSize* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_TypeIdentfierWithSize_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_TypeIdentfierWithSize_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18503,49 +17268,42 @@ void TypeIdentfierWithSizePubSubType::register_type_object_representation() TypeIdentifierWithDependenciesPubSubType::TypeIdentifierWithDependenciesPubSubType() { - setName("eprosima::fastdds::dds::xtypes::TypeIdentifierWithDependencies"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeIdentifierWithDependencies::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_TypeIdentifierWithDependencies_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::TypeIdentifierWithDependencies"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_TypeIdentifierWithDependencies_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_TypeIdentifierWithDependencies_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_TypeIdentifierWithDependencies_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_TypeIdentifierWithDependencies_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_TypeIdentifierWithDependencies_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeIdentifierWithDependenciesPubSubType::~TypeIdentifierWithDependenciesPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeIdentifierWithDependenciesPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeIdentifierWithDependencies* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18560,16 +17318,12 @@ bool TypeIdentifierWithDependenciesPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeIdentifierWithDependenciesPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18578,18 +17332,14 @@ bool TypeIdentifierWithDependenciesPubSubType::deserialize( TypeIdentifierWithDependencies* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18602,52 +17352,62 @@ bool TypeIdentifierWithDependenciesPubSubType::deserialize( return true; } -std::function TypeIdentifierWithDependenciesPubSubType::getSerializedSizeProvider( +uint32_t TypeIdentifierWithDependenciesPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* TypeIdentifierWithDependenciesPubSubType::createData() + 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* TypeIdentifierWithDependenciesPubSubType::create_data() { return reinterpret_cast(new TypeIdentifierWithDependencies()); } -void TypeIdentifierWithDependenciesPubSubType::deleteData( +void TypeIdentifierWithDependenciesPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool TypeIdentifierWithDependenciesPubSubType::getKey( +bool TypeIdentifierWithDependenciesPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + TypeIdentifierWithDependencies data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool TypeIdentifierWithDependenciesPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18655,35 +17415,27 @@ bool TypeIdentifierWithDependenciesPubSubType::getKey( const TypeIdentifierWithDependencies* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_TypeIdentifierWithDependencies_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_TypeIdentifierWithDependencies_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18698,49 +17450,42 @@ void TypeIdentifierWithDependenciesPubSubType::register_type_object_representati TypeInformationPubSubType::TypeInformationPubSubType() { - setName("eprosima::fastdds::dds::xtypes::TypeInformation"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(TypeInformation::getMaxCdrSerializedSize()); -#else - eprosima_fastdds_dds_xtypes_TypeInformation_max_cdr_typesize; -#endif + set_name("eprosima::fastdds::dds::xtypes::TypeInformation"); + uint32_t type_size = eprosima_fastdds_dds_xtypes_TypeInformation_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_dds_xtypes_TypeInformation_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_TypeInformation_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_dds_xtypes_TypeInformation_max_key_cdr_typesize > 16 ? eprosima_fastdds_dds_xtypes_TypeInformation_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TypeInformationPubSubType::~TypeInformationPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TypeInformationPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TypeInformation* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18755,16 +17500,12 @@ bool TypeInformationPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TypeInformationPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18773,18 +17514,14 @@ bool TypeInformationPubSubType::deserialize( TypeInformation* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18797,52 +17534,62 @@ bool TypeInformationPubSubType::deserialize( return true; } -std::function TypeInformationPubSubType::getSerializedSizeProvider( +uint32_t TypeInformationPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* TypeInformationPubSubType::createData() + 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* TypeInformationPubSubType::create_data() { return reinterpret_cast(new TypeInformation()); } -void TypeInformationPubSubType::deleteData( +void TypeInformationPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool TypeInformationPubSubType::getKey( +bool TypeInformationPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + TypeInformation data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool TypeInformationPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18850,35 +17597,27 @@ bool TypeInformationPubSubType::getKey( const TypeInformation* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_dds_xtypes_TypeInformation_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_dds_xtypes_TypeInformation_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp index 5188a5562a9..36273a53f0a 100644 --- a/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp @@ -575,10 +575,10 @@ bool DomainParticipantImpl::find_or_create_topic_and_type( efd::TopicDescription* topic_desc = lookup_topicdescription(topic_name); if (nullptr != topic_desc) { - if (topic_desc->get_type_name() != type->getName()) + if (topic_desc->get_type_name() != type->get_name()) { EPROSIMA_LOG_ERROR(STATISTICS_DOMAIN_PARTICIPANT, - topic_name << " is not using expected type " << type->getName() << + topic_name << " is not using expected type " << type->get_name() << " and is using instead type " << topic_desc->get_type_name()); return false; } @@ -591,14 +591,14 @@ bool DomainParticipantImpl::find_or_create_topic_and_type( } else { - if (efd::RETCODE_PRECONDITION_NOT_MET == register_type(type, type->getName())) + if (efd::RETCODE_PRECONDITION_NOT_MET == register_type(type, type->get_name())) { // No log because it is already logged within register_type return false; } // Create topic. No need to check return pointer. It fails if the topic already exists, if the QoS is // inconsistent or if the type is not registered. - *topic = create_topic(topic_name, type->getName(), efd::TOPIC_QOS_DEFAULT); + *topic = create_topic(topic_name, type->get_name(), efd::TOPIC_QOS_DEFAULT); } assert(nullptr != *topic); return true; diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index d2342534215..b77afbe374b 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -374,14 +374,14 @@ bool MonitorService::add_change( const bool& disposed) { InstanceHandle_t handle; - type_.getKey(&status_data, &handle, false); + type_.compute_key(&status_data, handle, false); CacheChange_t* change = status_writer_history_->create_change( (disposed ? fastdds::rtps::NOT_ALIVE_DISPOSED_UNREGISTERED : fastdds::rtps::ALIVE), handle); if (nullptr != change) { - uint32_t cdr_size = type_.getSerializedSizeProvider(&status_data)(); + uint32_t cdr_size = type_.calculate_serialized_size(&status_data, fastdds::dds::DEFAULT_DATA_REPRESENTATION); if (!status_writer_payload_pool_->get_payload(cdr_size, change->serializedPayload)) { status_writer_history_->release_change(change); @@ -393,7 +393,7 @@ bool MonitorService::add_change( { CDRMessage_t aux_msg(change->serializedPayload); - if (!type_.serialize(&status_data, &change->serializedPayload)) + if (!type_.serialize(&status_data, change->serializedPayload, fastdds::dds::DEFAULT_DATA_REPRESENTATION)) { EPROSIMA_LOG_ERROR(MONITOR_SERVICE, "Serialization failed"); status_writer_history_->release_change(change); @@ -440,7 +440,7 @@ bool MonitorService::create_endpoint() watts.endpoint.properties.properties().push_back(std::move(property)); HistoryAttributes hatt; - hatt.payloadMaxSize = type_.m_typeSize; + hatt.payloadMaxSize = type_.max_serialized_type_size; hatt.memoryPolicy = MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; hatt.initialReservedCaches = 25; hatt.maximumReservedCaches = 0; @@ -460,7 +460,7 @@ bool MonitorService::create_endpoint() status_writer_history_.reset(new eprosima::fastdds::dds::DataWriterHistory( status_writer_payload_pool_, std::make_shared(writer_pool_cfg), - tatt, type_.m_typeSize, + tatt, type_.max_serialized_type_size, MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE, []( const InstanceHandle_t& ) -> void @@ -488,7 +488,7 @@ bool MonitorService::create_endpoint() TopicAttributes tatts; tatts.topicName = MONITOR_SERVICE_TOPIC; - tatts.topicDataType = type_.getName(); + tatts.topicDataType = type_.get_name(); tatts.topicKind = WITH_KEY; endpoint_registrator_(status_writer_, tatts, wqos); diff --git a/src/cpp/statistics/types/monitorservice_typesPubSubTypes.cxx b/src/cpp/statistics/types/monitorservice_typesPubSubTypes.cxx index d0e23ab6f51..7918dca6ede 100644 --- a/src/cpp/statistics/types/monitorservice_typesPubSubTypes.cxx +++ b/src/cpp/statistics/types/monitorservice_typesPubSubTypes.cxx @@ -36,49 +36,42 @@ namespace eprosima { namespace statistics { ConnectionPubSubType::ConnectionPubSubType() { - setName("eprosima::fastdds::statistics::Connection"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Connection::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_Connection_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::Connection"); + uint32_t type_size = eprosima_fastdds_statistics_Connection_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_Connection_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Connection_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_Connection_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Connection_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ConnectionPubSubType::~ConnectionPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ConnectionPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Connection* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -93,16 +86,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ConnectionPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -111,18 +100,14 @@ namespace eprosima { Connection* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -135,52 +120,62 @@ namespace eprosima { return true; } - std::function ConnectionPubSubType::getSerializedSizeProvider( + uint32_t ConnectionPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* ConnectionPubSubType::createData() + 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* ConnectionPubSubType::create_data() { return reinterpret_cast(new Connection()); } - void ConnectionPubSubType::deleteData( + void ConnectionPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool ConnectionPubSubType::getKey( + bool ConnectionPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Connection data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool ConnectionPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -188,35 +183,27 @@ namespace eprosima { const Connection* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_Connection_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_Connection_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -229,49 +216,42 @@ namespace eprosima { QosPolicyCount_sPubSubType::QosPolicyCount_sPubSubType() { - setName("eprosima::fastdds::statistics::QosPolicyCount_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(QosPolicyCount_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_QosPolicyCount_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::QosPolicyCount_s"); + uint32_t type_size = eprosima_fastdds_statistics_QosPolicyCount_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } QosPolicyCount_sPubSubType::~QosPolicyCount_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool QosPolicyCount_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const QosPolicyCount_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -286,16 +266,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool QosPolicyCount_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -304,18 +280,14 @@ namespace eprosima { QosPolicyCount_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -328,52 +300,62 @@ namespace eprosima { return true; } - std::function QosPolicyCount_sPubSubType::getSerializedSizeProvider( + uint32_t QosPolicyCount_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* QosPolicyCount_sPubSubType::createData() + 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* QosPolicyCount_sPubSubType::create_data() { return reinterpret_cast(new QosPolicyCount_s()); } - void QosPolicyCount_sPubSubType::deleteData( + void QosPolicyCount_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool QosPolicyCount_sPubSubType::getKey( + bool QosPolicyCount_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + QosPolicyCount_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool QosPolicyCount_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -381,35 +363,27 @@ namespace eprosima { const QosPolicyCount_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -422,49 +396,42 @@ namespace eprosima { BaseStatus_sPubSubType::BaseStatus_sPubSubType() { - setName("eprosima::fastdds::statistics::BaseStatus_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(BaseStatus_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_BaseStatus_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::BaseStatus_s"); + uint32_t type_size = eprosima_fastdds_statistics_BaseStatus_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BaseStatus_sPubSubType::~BaseStatus_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BaseStatus_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BaseStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -479,16 +446,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BaseStatus_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -497,18 +460,14 @@ namespace eprosima { BaseStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -521,52 +480,62 @@ namespace eprosima { return true; } - std::function BaseStatus_sPubSubType::getSerializedSizeProvider( + uint32_t BaseStatus_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* BaseStatus_sPubSubType::createData() + 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* BaseStatus_sPubSubType::create_data() { return reinterpret_cast(new BaseStatus_s()); } - void BaseStatus_sPubSubType::deleteData( + void BaseStatus_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool BaseStatus_sPubSubType::getKey( + bool BaseStatus_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + BaseStatus_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool BaseStatus_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -574,35 +543,27 @@ namespace eprosima { const BaseStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -616,49 +577,42 @@ namespace eprosima { IncompatibleQoSStatus_sPubSubType::IncompatibleQoSStatus_sPubSubType() { - setName("eprosima::fastdds::statistics::IncompatibleQoSStatus_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(IncompatibleQoSStatus_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::IncompatibleQoSStatus_s"); + uint32_t type_size = eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } IncompatibleQoSStatus_sPubSubType::~IncompatibleQoSStatus_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool IncompatibleQoSStatus_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const IncompatibleQoSStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -673,16 +627,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool IncompatibleQoSStatus_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -691,18 +641,14 @@ namespace eprosima { IncompatibleQoSStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -715,52 +661,62 @@ namespace eprosima { return true; } - std::function IncompatibleQoSStatus_sPubSubType::getSerializedSizeProvider( + uint32_t IncompatibleQoSStatus_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* IncompatibleQoSStatus_sPubSubType::createData() + 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* IncompatibleQoSStatus_sPubSubType::create_data() { return reinterpret_cast(new IncompatibleQoSStatus_s()); } - void IncompatibleQoSStatus_sPubSubType::deleteData( + void IncompatibleQoSStatus_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool IncompatibleQoSStatus_sPubSubType::getKey( + bool IncompatibleQoSStatus_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + IncompatibleQoSStatus_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool IncompatibleQoSStatus_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -768,35 +724,27 @@ namespace eprosima { const IncompatibleQoSStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -809,49 +757,42 @@ namespace eprosima { LivelinessChangedStatus_sPubSubType::LivelinessChangedStatus_sPubSubType() { - setName("eprosima::fastdds::statistics::LivelinessChangedStatus_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(LivelinessChangedStatus_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::LivelinessChangedStatus_s"); + uint32_t type_size = eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } LivelinessChangedStatus_sPubSubType::~LivelinessChangedStatus_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool LivelinessChangedStatus_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const LivelinessChangedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -866,16 +807,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool LivelinessChangedStatus_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -884,18 +821,14 @@ namespace eprosima { LivelinessChangedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -908,52 +841,62 @@ namespace eprosima { return true; } - std::function LivelinessChangedStatus_sPubSubType::getSerializedSizeProvider( + uint32_t LivelinessChangedStatus_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* LivelinessChangedStatus_sPubSubType::createData() + 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* LivelinessChangedStatus_sPubSubType::create_data() { return reinterpret_cast(new LivelinessChangedStatus_s()); } - void LivelinessChangedStatus_sPubSubType::deleteData( + void LivelinessChangedStatus_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool LivelinessChangedStatus_sPubSubType::getKey( + bool LivelinessChangedStatus_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + LivelinessChangedStatus_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool LivelinessChangedStatus_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -961,35 +904,27 @@ namespace eprosima { const LivelinessChangedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1002,49 +937,42 @@ namespace eprosima { DeadlineMissedStatus_sPubSubType::DeadlineMissedStatus_sPubSubType() { - setName("eprosima::fastdds::statistics::DeadlineMissedStatus_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(DeadlineMissedStatus_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::DeadlineMissedStatus_s"); + uint32_t type_size = eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DeadlineMissedStatus_sPubSubType::~DeadlineMissedStatus_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DeadlineMissedStatus_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const DeadlineMissedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1059,16 +987,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DeadlineMissedStatus_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1077,18 +1001,14 @@ namespace eprosima { DeadlineMissedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1101,52 +1021,62 @@ namespace eprosima { return true; } - std::function DeadlineMissedStatus_sPubSubType::getSerializedSizeProvider( + uint32_t DeadlineMissedStatus_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* DeadlineMissedStatus_sPubSubType::createData() + 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* DeadlineMissedStatus_sPubSubType::create_data() { return reinterpret_cast(new DeadlineMissedStatus_s()); } - void DeadlineMissedStatus_sPubSubType::deleteData( + void DeadlineMissedStatus_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool DeadlineMissedStatus_sPubSubType::getKey( + bool DeadlineMissedStatus_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + DeadlineMissedStatus_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool DeadlineMissedStatus_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1154,35 +1084,27 @@ namespace eprosima { const DeadlineMissedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1202,49 +1124,42 @@ namespace eprosima { MonitorServiceStatusDataPubSubType::MonitorServiceStatusDataPubSubType() { - setName("eprosima::fastdds::statistics::MonitorServiceStatusData"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(MonitorServiceStatusData::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_MonitorServiceStatusData_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::MonitorServiceStatusData"); + uint32_t type_size = eprosima_fastdds_statistics_MonitorServiceStatusData_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MonitorServiceStatusDataPubSubType::~MonitorServiceStatusDataPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MonitorServiceStatusDataPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MonitorServiceStatusData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1259,16 +1174,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MonitorServiceStatusDataPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1277,18 +1188,14 @@ namespace eprosima { MonitorServiceStatusData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1301,52 +1208,62 @@ namespace eprosima { return true; } - std::function MonitorServiceStatusDataPubSubType::getSerializedSizeProvider( + uint32_t MonitorServiceStatusDataPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* MonitorServiceStatusDataPubSubType::createData() + 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* MonitorServiceStatusDataPubSubType::create_data() { return reinterpret_cast(new MonitorServiceStatusData()); } - void MonitorServiceStatusDataPubSubType::deleteData( + void MonitorServiceStatusDataPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool MonitorServiceStatusDataPubSubType::getKey( + bool MonitorServiceStatusDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + MonitorServiceStatusData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool MonitorServiceStatusDataPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1354,35 +1271,27 @@ namespace eprosima { const MonitorServiceStatusData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/src/cpp/statistics/types/monitorservice_typesPubSubTypes.hpp b/src/cpp/statistics/types/monitorservice_typesPubSubTypes.hpp index 966a6a459c8..5c62a2bba76 100644 --- a/src/cpp/statistics/types/monitorservice_typesPubSubTypes.hpp +++ b/src/cpp/statistics/types/monitorservice_typesPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated monitorservice_types is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER namespace eprosima { @@ -61,38 +61,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -107,10 +99,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -131,8 +119,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -152,38 +142,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -198,10 +180,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -222,8 +200,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -243,38 +223,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -289,10 +261,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -313,8 +281,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector QosPolicyCountSeq_s; @@ -335,38 +305,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -381,10 +343,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -405,8 +363,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -426,38 +386,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -472,10 +424,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -496,8 +444,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -517,38 +467,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -563,10 +505,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -587,8 +525,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef eprosima::fastdds::statistics::BaseStatus_s LivelinessLostStatus_s; @@ -625,38 +565,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -671,10 +603,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -695,8 +623,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace statistics diff --git a/src/cpp/statistics/types/typesPubSubTypes.cxx b/src/cpp/statistics/types/typesPubSubTypes.cxx index fbc16b14e72..f2ad0bcbf73 100644 --- a/src/cpp/statistics/types/typesPubSubTypes.cxx +++ b/src/cpp/statistics/types/typesPubSubTypes.cxx @@ -37,49 +37,42 @@ namespace eprosima { namespace detail { EntityId_sPubSubType::EntityId_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::EntityId_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(EntityId_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_EntityId_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::EntityId_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_EntityId_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EntityId_sPubSubType::~EntityId_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EntityId_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EntityId_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -94,16 +87,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EntityId_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -112,18 +101,14 @@ namespace eprosima { EntityId_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -136,52 +121,62 @@ namespace eprosima { return true; } - std::function EntityId_sPubSubType::getSerializedSizeProvider( + uint32_t EntityId_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* EntityId_sPubSubType::createData() + 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* EntityId_sPubSubType::create_data() { return reinterpret_cast(new EntityId_s()); } - void EntityId_sPubSubType::deleteData( + void EntityId_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool EntityId_sPubSubType::getKey( + bool EntityId_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + EntityId_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool EntityId_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -189,35 +184,27 @@ namespace eprosima { const EntityId_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -230,49 +217,42 @@ namespace eprosima { GuidPrefix_sPubSubType::GuidPrefix_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::GuidPrefix_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(GuidPrefix_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_GuidPrefix_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::GuidPrefix_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_GuidPrefix_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } GuidPrefix_sPubSubType::~GuidPrefix_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool GuidPrefix_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const GuidPrefix_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -287,16 +267,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool GuidPrefix_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -305,18 +281,14 @@ namespace eprosima { GuidPrefix_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -329,52 +301,62 @@ namespace eprosima { return true; } - std::function GuidPrefix_sPubSubType::getSerializedSizeProvider( + uint32_t GuidPrefix_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* GuidPrefix_sPubSubType::createData() + 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* GuidPrefix_sPubSubType::create_data() { return reinterpret_cast(new GuidPrefix_s()); } - void GuidPrefix_sPubSubType::deleteData( + void GuidPrefix_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool GuidPrefix_sPubSubType::getKey( + bool GuidPrefix_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + GuidPrefix_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool GuidPrefix_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -382,35 +364,27 @@ namespace eprosima { const GuidPrefix_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -423,49 +397,42 @@ namespace eprosima { GUID_sPubSubType::GUID_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::GUID_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(GUID_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_GUID_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::GUID_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_GUID_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } GUID_sPubSubType::~GUID_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool GUID_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const GUID_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -480,16 +447,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool GUID_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -498,18 +461,14 @@ namespace eprosima { GUID_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -522,52 +481,62 @@ namespace eprosima { return true; } - std::function GUID_sPubSubType::getSerializedSizeProvider( + uint32_t GUID_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* GUID_sPubSubType::createData() + 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* GUID_sPubSubType::create_data() { return reinterpret_cast(new GUID_s()); } - void GUID_sPubSubType::deleteData( + void GUID_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool GUID_sPubSubType::getKey( + bool GUID_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + GUID_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool GUID_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -575,35 +544,27 @@ namespace eprosima { const GUID_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -616,49 +577,42 @@ namespace eprosima { SequenceNumber_sPubSubType::SequenceNumber_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::SequenceNumber_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceNumber_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_SequenceNumber_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::SequenceNumber_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_SequenceNumber_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceNumber_sPubSubType::~SequenceNumber_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceNumber_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceNumber_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -673,16 +627,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceNumber_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -691,18 +641,14 @@ namespace eprosima { SequenceNumber_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -715,52 +661,62 @@ namespace eprosima { return true; } - std::function SequenceNumber_sPubSubType::getSerializedSizeProvider( + uint32_t SequenceNumber_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* SequenceNumber_sPubSubType::createData() + 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* SequenceNumber_sPubSubType::create_data() { return reinterpret_cast(new SequenceNumber_s()); } - void SequenceNumber_sPubSubType::deleteData( + void SequenceNumber_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool SequenceNumber_sPubSubType::getKey( + bool SequenceNumber_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + SequenceNumber_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool SequenceNumber_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -768,35 +724,27 @@ namespace eprosima { const SequenceNumber_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -809,49 +757,42 @@ namespace eprosima { SampleIdentity_sPubSubType::SampleIdentity_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::SampleIdentity_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(SampleIdentity_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_SampleIdentity_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::SampleIdentity_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_SampleIdentity_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SampleIdentity_sPubSubType::~SampleIdentity_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SampleIdentity_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SampleIdentity_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -866,16 +807,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SampleIdentity_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -884,18 +821,14 @@ namespace eprosima { SampleIdentity_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -908,52 +841,62 @@ namespace eprosima { return true; } - std::function SampleIdentity_sPubSubType::getSerializedSizeProvider( + uint32_t SampleIdentity_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* SampleIdentity_sPubSubType::createData() + 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* SampleIdentity_sPubSubType::create_data() { return reinterpret_cast(new SampleIdentity_s()); } - void SampleIdentity_sPubSubType::deleteData( + void SampleIdentity_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool SampleIdentity_sPubSubType::getKey( + bool SampleIdentity_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + SampleIdentity_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool SampleIdentity_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -961,35 +904,27 @@ namespace eprosima { const SampleIdentity_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1002,49 +937,42 @@ namespace eprosima { Locator_sPubSubType::Locator_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::Locator_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Locator_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_Locator_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::Locator_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_Locator_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Locator_sPubSubType::~Locator_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Locator_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Locator_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1059,16 +987,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Locator_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1077,18 +1001,14 @@ namespace eprosima { Locator_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1101,52 +1021,62 @@ namespace eprosima { return true; } - std::function Locator_sPubSubType::getSerializedSizeProvider( + uint32_t Locator_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Locator_sPubSubType::createData() + 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* Locator_sPubSubType::create_data() { return reinterpret_cast(new Locator_s()); } - void Locator_sPubSubType::deleteData( + void Locator_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Locator_sPubSubType::getKey( + bool Locator_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Locator_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Locator_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1154,35 +1084,27 @@ namespace eprosima { const Locator_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1197,49 +1119,42 @@ namespace eprosima { DiscoveryTimePubSubType::DiscoveryTimePubSubType() { - setName("eprosima::fastdds::statistics::DiscoveryTime"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(DiscoveryTime::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_DiscoveryTime_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::DiscoveryTime"); + uint32_t type_size = eprosima_fastdds_statistics_DiscoveryTime_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DiscoveryTimePubSubType::~DiscoveryTimePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DiscoveryTimePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const DiscoveryTime* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1254,16 +1169,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DiscoveryTimePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1272,18 +1183,14 @@ namespace eprosima { DiscoveryTime* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1296,52 +1203,62 @@ namespace eprosima { return true; } - std::function DiscoveryTimePubSubType::getSerializedSizeProvider( + uint32_t DiscoveryTimePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* DiscoveryTimePubSubType::createData() + 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* DiscoveryTimePubSubType::create_data() { return reinterpret_cast(new DiscoveryTime()); } - void DiscoveryTimePubSubType::deleteData( + void DiscoveryTimePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool DiscoveryTimePubSubType::getKey( + bool DiscoveryTimePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + DiscoveryTime data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool DiscoveryTimePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1349,35 +1266,27 @@ namespace eprosima { const DiscoveryTime* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1390,49 +1299,42 @@ namespace eprosima { EntityCountPubSubType::EntityCountPubSubType() { - setName("eprosima::fastdds::statistics::EntityCount"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(EntityCount::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_EntityCount_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::EntityCount"); + uint32_t type_size = eprosima_fastdds_statistics_EntityCount_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EntityCountPubSubType::~EntityCountPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EntityCountPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EntityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1447,16 +1349,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EntityCountPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1465,18 +1363,14 @@ namespace eprosima { EntityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1489,52 +1383,62 @@ namespace eprosima { return true; } - std::function EntityCountPubSubType::getSerializedSizeProvider( + uint32_t EntityCountPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* EntityCountPubSubType::createData() + 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* EntityCountPubSubType::create_data() { return reinterpret_cast(new EntityCount()); } - void EntityCountPubSubType::deleteData( + void EntityCountPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool EntityCountPubSubType::getKey( + bool EntityCountPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + EntityCount data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool EntityCountPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1542,35 +1446,27 @@ namespace eprosima { const EntityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1583,49 +1479,42 @@ namespace eprosima { SampleIdentityCountPubSubType::SampleIdentityCountPubSubType() { - setName("eprosima::fastdds::statistics::SampleIdentityCount"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(SampleIdentityCount::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_SampleIdentityCount_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::SampleIdentityCount"); + uint32_t type_size = eprosima_fastdds_statistics_SampleIdentityCount_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SampleIdentityCountPubSubType::~SampleIdentityCountPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SampleIdentityCountPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SampleIdentityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1640,16 +1529,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SampleIdentityCountPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1658,18 +1543,14 @@ namespace eprosima { SampleIdentityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1682,52 +1563,62 @@ namespace eprosima { return true; } - std::function SampleIdentityCountPubSubType::getSerializedSizeProvider( + uint32_t SampleIdentityCountPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* SampleIdentityCountPubSubType::createData() + 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* SampleIdentityCountPubSubType::create_data() { return reinterpret_cast(new SampleIdentityCount()); } - void SampleIdentityCountPubSubType::deleteData( + void SampleIdentityCountPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool SampleIdentityCountPubSubType::getKey( + bool SampleIdentityCountPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + SampleIdentityCount data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool SampleIdentityCountPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1735,35 +1626,27 @@ namespace eprosima { const SampleIdentityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1776,49 +1659,42 @@ namespace eprosima { Entity2LocatorTrafficPubSubType::Entity2LocatorTrafficPubSubType() { - setName("eprosima::fastdds::statistics::Entity2LocatorTraffic"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Entity2LocatorTraffic::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_Entity2LocatorTraffic_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::Entity2LocatorTraffic"); + uint32_t type_size = eprosima_fastdds_statistics_Entity2LocatorTraffic_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Entity2LocatorTrafficPubSubType::~Entity2LocatorTrafficPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Entity2LocatorTrafficPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Entity2LocatorTraffic* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1833,16 +1709,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Entity2LocatorTrafficPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1851,18 +1723,14 @@ namespace eprosima { Entity2LocatorTraffic* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1875,52 +1743,62 @@ namespace eprosima { return true; } - std::function Entity2LocatorTrafficPubSubType::getSerializedSizeProvider( + uint32_t Entity2LocatorTrafficPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Entity2LocatorTrafficPubSubType::createData() + 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* Entity2LocatorTrafficPubSubType::create_data() { return reinterpret_cast(new Entity2LocatorTraffic()); } - void Entity2LocatorTrafficPubSubType::deleteData( + void Entity2LocatorTrafficPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Entity2LocatorTrafficPubSubType::getKey( + bool Entity2LocatorTrafficPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Entity2LocatorTraffic data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Entity2LocatorTrafficPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1928,35 +1806,27 @@ namespace eprosima { const Entity2LocatorTraffic* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1969,49 +1839,42 @@ namespace eprosima { WriterReaderDataPubSubType::WriterReaderDataPubSubType() { - setName("eprosima::fastdds::statistics::WriterReaderData"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(WriterReaderData::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_WriterReaderData_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::WriterReaderData"); + uint32_t type_size = eprosima_fastdds_statistics_WriterReaderData_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } WriterReaderDataPubSubType::~WriterReaderDataPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool WriterReaderDataPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const WriterReaderData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2026,16 +1889,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool WriterReaderDataPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2044,18 +1903,14 @@ namespace eprosima { WriterReaderData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2068,52 +1923,62 @@ namespace eprosima { return true; } - std::function WriterReaderDataPubSubType::getSerializedSizeProvider( + uint32_t WriterReaderDataPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* WriterReaderDataPubSubType::createData() + 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* WriterReaderDataPubSubType::create_data() { return reinterpret_cast(new WriterReaderData()); } - void WriterReaderDataPubSubType::deleteData( + void WriterReaderDataPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool WriterReaderDataPubSubType::getKey( + bool WriterReaderDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + WriterReaderData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool WriterReaderDataPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2121,35 +1986,27 @@ namespace eprosima { const WriterReaderData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2162,49 +2019,42 @@ namespace eprosima { Locator2LocatorDataPubSubType::Locator2LocatorDataPubSubType() { - setName("eprosima::fastdds::statistics::Locator2LocatorData"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Locator2LocatorData::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_Locator2LocatorData_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::Locator2LocatorData"); + uint32_t type_size = eprosima_fastdds_statistics_Locator2LocatorData_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Locator2LocatorDataPubSubType::~Locator2LocatorDataPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Locator2LocatorDataPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Locator2LocatorData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2219,16 +2069,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Locator2LocatorDataPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2237,18 +2083,14 @@ namespace eprosima { Locator2LocatorData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2261,52 +2103,62 @@ namespace eprosima { return true; } - std::function Locator2LocatorDataPubSubType::getSerializedSizeProvider( + uint32_t Locator2LocatorDataPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Locator2LocatorDataPubSubType::createData() + 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* Locator2LocatorDataPubSubType::create_data() { return reinterpret_cast(new Locator2LocatorData()); } - void Locator2LocatorDataPubSubType::deleteData( + void Locator2LocatorDataPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Locator2LocatorDataPubSubType::getKey( + bool Locator2LocatorDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Locator2LocatorData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Locator2LocatorDataPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2314,35 +2166,27 @@ namespace eprosima { const Locator2LocatorData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2355,49 +2199,42 @@ namespace eprosima { EntityDataPubSubType::EntityDataPubSubType() { - setName("eprosima::fastdds::statistics::EntityData"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(EntityData::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_EntityData_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::EntityData"); + uint32_t type_size = eprosima_fastdds_statistics_EntityData_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EntityDataPubSubType::~EntityDataPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EntityDataPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EntityData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2412,16 +2249,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EntityDataPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2430,18 +2263,14 @@ namespace eprosima { EntityData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2454,52 +2283,62 @@ namespace eprosima { return true; } - std::function EntityDataPubSubType::getSerializedSizeProvider( + uint32_t EntityDataPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* EntityDataPubSubType::createData() + 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* EntityDataPubSubType::create_data() { return reinterpret_cast(new EntityData()); } - void EntityDataPubSubType::deleteData( + void EntityDataPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool EntityDataPubSubType::getKey( + bool EntityDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + EntityData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool EntityDataPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2507,35 +2346,27 @@ namespace eprosima { const EntityData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2548,49 +2379,42 @@ namespace eprosima { PhysicalDataPubSubType::PhysicalDataPubSubType() { - setName("eprosima::fastdds::statistics::PhysicalData"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(PhysicalData::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_PhysicalData_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::PhysicalData"); + uint32_t type_size = eprosima_fastdds_statistics_PhysicalData_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PhysicalDataPubSubType::~PhysicalDataPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PhysicalDataPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PhysicalData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2605,16 +2429,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PhysicalDataPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2623,18 +2443,14 @@ namespace eprosima { PhysicalData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2647,52 +2463,62 @@ namespace eprosima { return true; } - std::function PhysicalDataPubSubType::getSerializedSizeProvider( + uint32_t PhysicalDataPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* PhysicalDataPubSubType::createData() + 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* PhysicalDataPubSubType::create_data() { return reinterpret_cast(new PhysicalData()); } - void PhysicalDataPubSubType::deleteData( + void PhysicalDataPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool PhysicalDataPubSubType::getKey( + bool PhysicalDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + PhysicalData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool PhysicalDataPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2700,35 +2526,27 @@ namespace eprosima { const PhysicalData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/src/cpp/statistics/types/typesPubSubTypes.hpp b/src/cpp/statistics/types/typesPubSubTypes.hpp index fb99b8c567d..3a7c7aa0ad6 100644 --- a/src/cpp/statistics/types/typesPubSubTypes.hpp +++ b/src/cpp/statistics/types/typesPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "types.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated types is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER namespace eprosima { @@ -62,38 +62,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -108,10 +100,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -132,8 +120,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -153,38 +143,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -199,10 +181,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -223,8 +201,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -244,38 +224,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -290,10 +262,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -314,8 +282,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -335,38 +305,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -381,10 +343,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -405,8 +363,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -426,38 +386,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -472,10 +424,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -496,8 +444,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -517,38 +467,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -563,10 +505,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -587,8 +525,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace detail @@ -609,38 +549,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -655,10 +587,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -679,8 +607,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -700,38 +630,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -746,10 +668,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -770,8 +688,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -791,38 +711,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -837,10 +749,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -861,8 +769,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -882,38 +792,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -928,10 +830,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -952,8 +850,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -973,38 +873,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1019,10 +911,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1043,8 +931,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1064,38 +954,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1110,10 +992,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1134,8 +1012,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1155,38 +1035,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1201,10 +1073,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1225,8 +1093,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1246,38 +1116,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1292,10 +1154,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1316,8 +1174,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; namespace EventKind diff --git a/test/blackbox/api/dds-pim/PubSubParticipant.hpp b/test/blackbox/api/dds-pim/PubSubParticipant.hpp index ab968fef730..f3ecd2d63d0 100644 --- a/test/blackbox/api/dds-pim/PubSubParticipant.hpp +++ b/test/blackbox/api/dds-pim/PubSubParticipant.hpp @@ -345,7 +345,7 @@ class PubSubParticipant if (topic == nullptr) { topic = participant_->create_topic(publisher_topicname_, - type_->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); } if (topic) { @@ -382,7 +382,7 @@ class PubSubParticipant if (topic == nullptr) { topic = participant_->create_topic(subscriber_topicname_, - type_->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); } if (topic) { diff --git a/test/blackbox/api/dds-pim/PubSubReader.hpp b/test/blackbox/api/dds-pim/PubSubReader.hpp index 4daac8e5097..9c3c361f416 100644 --- a/test/blackbox/api/dds-pim/PubSubReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubReader.hpp @@ -445,7 +445,7 @@ class PubSubReader // Create topic topic_ = - participant_->create_topic(topic_name_, type_->getName(), + participant_->create_topic(topic_name_, type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); ASSERT_NE(topic_, nullptr); ASSERT_TRUE(topic_->is_enabled()); diff --git a/test/blackbox/api/dds-pim/PubSubWriter.hpp b/test/blackbox/api/dds-pim/PubSubWriter.hpp index 8b8d75632d9..230369965ff 100644 --- a/test/blackbox/api/dds-pim/PubSubWriter.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriter.hpp @@ -407,7 +407,7 @@ class PubSubWriter ASSERT_EQ(participant_->register_type(type_), eprosima::fastdds::dds::RETCODE_OK); // Create topic - topic_ = participant_->create_topic(topic_name_, type_->getName(), + topic_ = participant_->create_topic(topic_name_, type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); ASSERT_NE(topic_, nullptr); ASSERT_TRUE(topic_->is_enabled()); diff --git a/test/blackbox/api/dds-pim/PubSubWriterReader.hpp b/test/blackbox/api/dds-pim/PubSubWriterReader.hpp index 3f5da3a8750..57f8a58d5ed 100644 --- a/test/blackbox/api/dds-pim/PubSubWriterReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriterReader.hpp @@ -413,7 +413,7 @@ class PubSubWriterReader // Create topic topic_ = - participant_->create_topic(topic_name_, type_->getName(), + participant_->create_topic(topic_name_, type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); ASSERT_NE(topic_, nullptr); ASSERT_TRUE(topic_->is_enabled()); @@ -449,7 +449,7 @@ class PubSubWriterReader { topic_name += suffix; eprosima::fastdds::dds::Topic* topic = participant_->create_topic(topic_name, - type_->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); ret_val &= (nullptr != topic); if (!ret_val) { diff --git a/test/blackbox/api/dds-pim/ReqRepHelloWorldReplier.cpp b/test/blackbox/api/dds-pim/ReqRepHelloWorldReplier.cpp index 2b4689ce462..e2af5fe150d 100644 --- a/test/blackbox/api/dds-pim/ReqRepHelloWorldReplier.cpp +++ b/test/blackbox/api/dds-pim/ReqRepHelloWorldReplier.cpp @@ -101,13 +101,13 @@ void ReqRepHelloWorldReplier::init() configDatareader("Request"); request_topic_ = participant_->create_topic(datareader_topicname_, - type_->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); ASSERT_NE(request_topic_, nullptr); ASSERT_TRUE(request_topic_->is_enabled()); configDatawriter("Reply"); reply_topic_ = participant_->create_topic(datawriter_topicname_, - type_->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); ASSERT_NE(reply_topic_, nullptr); ASSERT_TRUE(reply_topic_->is_enabled()); diff --git a/test/blackbox/api/dds-pim/ReqRepHelloWorldRequester.cpp b/test/blackbox/api/dds-pim/ReqRepHelloWorldRequester.cpp index 359bac358ce..c055db9db22 100644 --- a/test/blackbox/api/dds-pim/ReqRepHelloWorldRequester.cpp +++ b/test/blackbox/api/dds-pim/ReqRepHelloWorldRequester.cpp @@ -106,13 +106,13 @@ void ReqRepHelloWorldRequester::init() configDatareader("Reply"); reply_topic_ = participant_->create_topic(datareader_topicname_, - type_->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); ASSERT_NE(reply_topic_, nullptr); ASSERT_TRUE(reply_topic_->is_enabled()); configDatawriter("Request"); request_topic_ = participant_->create_topic(datawriter_topicname_, - type_->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); ASSERT_NE(request_topic_, nullptr); ASSERT_TRUE(request_topic_->is_enabled()); diff --git a/test/blackbox/api/dds-pim/TCPReqRepHelloWorldReplier.cpp b/test/blackbox/api/dds-pim/TCPReqRepHelloWorldReplier.cpp index eb9b91f60a8..9699b2f09c3 100644 --- a/test/blackbox/api/dds-pim/TCPReqRepHelloWorldReplier.cpp +++ b/test/blackbox/api/dds-pim/TCPReqRepHelloWorldReplier.cpp @@ -146,13 +146,13 @@ void TCPReqRepHelloWorldReplier::init( configDatareader("Request"); request_topic_ = participant_->create_topic(datareader_topicname_, - type_->getName(), TOPIC_QOS_DEFAULT); + type_->get_name(), TOPIC_QOS_DEFAULT); ASSERT_NE(request_topic_, nullptr); ASSERT_TRUE(request_topic_->is_enabled()); configDatawriter("Reply"); reply_topic_ = participant_->create_topic(datawriter_topicname_, - type_->getName(), TOPIC_QOS_DEFAULT); + type_->get_name(), TOPIC_QOS_DEFAULT); ASSERT_NE(reply_topic_, nullptr); ASSERT_TRUE(reply_topic_->is_enabled()); diff --git a/test/blackbox/api/dds-pim/TCPReqRepHelloWorldRequester.cpp b/test/blackbox/api/dds-pim/TCPReqRepHelloWorldRequester.cpp index 47fb1274a77..00aab3af949 100644 --- a/test/blackbox/api/dds-pim/TCPReqRepHelloWorldRequester.cpp +++ b/test/blackbox/api/dds-pim/TCPReqRepHelloWorldRequester.cpp @@ -200,13 +200,13 @@ void TCPReqRepHelloWorldRequester::init( configDatareader("Reply"); reply_topic_ = participant_->create_topic(datareader_topicname_, - type_->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); ASSERT_NE(reply_topic_, nullptr); ASSERT_TRUE(reply_topic_->is_enabled()); configDatawriter("Request"); request_topic_ = participant_->create_topic(datawriter_topicname_, - type_->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + type_->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); ASSERT_NE(request_topic_, nullptr); ASSERT_TRUE(request_topic_->is_enabled()); diff --git a/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp b/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp index 1ffcd52eb60..53eb5690a9f 100644 --- a/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp +++ b/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp @@ -608,7 +608,7 @@ TEST(DDSContentFilter, CorrectlyHandleAliasOtherHeader) throw std::runtime_error("Failed to create subscriber"); } - auto topic = participant->create_topic("TestTopic", type->getName(), TOPIC_QOS_DEFAULT); + auto topic = participant->create_topic("TestTopic", type->get_name(), TOPIC_QOS_DEFAULT); if (topic == nullptr) { throw std::runtime_error("Failed to create topic"); diff --git a/test/blackbox/common/DDSBlackboxTestsDataRepresentationQos.cpp b/test/blackbox/common/DDSBlackboxTestsDataRepresentationQos.cpp index f7fd4247456..28b480582e3 100644 --- a/test/blackbox/common/DDSBlackboxTestsDataRepresentationQos.cpp +++ b/test/blackbox/common/DDSBlackboxTestsDataRepresentationQos.cpp @@ -32,7 +32,7 @@ class MockHelloWorldPubSubType : public HelloWorldPubSubType bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, DataRepresentationId_t data_representation) override { last_data_representation = data_representation; @@ -41,11 +41,11 @@ class MockHelloWorldPubSubType : public HelloWorldPubSubType } bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override { // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + 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); diff --git a/test/blackbox/common/DDSBlackboxTestsDiscovery.cpp b/test/blackbox/common/DDSBlackboxTestsDiscovery.cpp index 0a7b1d0fad6..b0ddc6ad7a5 100644 --- a/test/blackbox/common/DDSBlackboxTestsDiscovery.cpp +++ b/test/blackbox/common/DDSBlackboxTestsDiscovery.cpp @@ -1746,7 +1746,7 @@ static void test_DDSDiscovery_WaitSetMatchedStatus( fastdds::dds::TypeSupport type(new HelloWorldPubSubType()); EXPECT_EQ(type.register_type(participant), eprosima::fastdds::dds::RETCODE_OK); - auto topic = participant->create_topic(TEST_TOPIC_NAME, type->getName(), fastdds::dds::TOPIC_QOS_DEFAULT); + auto topic = participant->create_topic(TEST_TOPIC_NAME, type->get_name(), fastdds::dds::TOPIC_QOS_DEFAULT); ASSERT_NE(topic, nullptr); auto publisher = participant->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT); diff --git a/test/blackbox/common/DDSBlackboxTestsFindTopic.cpp b/test/blackbox/common/DDSBlackboxTestsFindTopic.cpp index 729dce34f14..64800b5da76 100644 --- a/test/blackbox/common/DDSBlackboxTestsFindTopic.cpp +++ b/test/blackbox/common/DDSBlackboxTestsFindTopic.cpp @@ -53,43 +53,53 @@ class DDSFindTopicTest : public testing::Test TestType() : TopicDataType() { - m_isGetKeyDefined = false; - m_typeSize = 16; + is_compute_key_provided = false; + max_serialized_type_size = 16; } bool serialize( const void* const, - fastdds::rtps::SerializedPayload_t*) override + fastdds::rtps::SerializedPayload_t&, + fastdds::dds::DataRepresentationId_t) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t*, + fastdds::rtps::SerializedPayload_t&, void*) override { return true; } - std::function getSerializedSizeProvider( - const void* const) override + uint32_t calculate_serialized_size( + const void* const, + fastdds::dds::DataRepresentationId_t) override { - return {}; + return 0u; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void*) override { } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t&, + fastdds::rtps::InstanceHandle_t&, + bool) override + { + return true; + } + + bool compute_key( const void* const, - fastdds::rtps::InstanceHandle_t*, + fastdds::rtps::InstanceHandle_t&, bool) override { return false; @@ -97,7 +107,7 @@ class DDSFindTopicTest : public testing::Test private: - using TopicDataType::getSerializedSizeProvider; + using TopicDataType::calculate_serialized_size; using TopicDataType::serialize; }; @@ -112,7 +122,7 @@ class DDSFindTopicTest : public testing::Test ASSERT_NE(nullptr, participant_); type_.reset(new TestType); - type_->setName(c_type_name); + type_->set_name(c_type_name); participant_->register_type(type_); } diff --git a/test/blackbox/common/DDSBlackboxTestsListeners.cpp b/test/blackbox/common/DDSBlackboxTestsListeners.cpp index 8fad1df288f..cc5c08837ad 100644 --- a/test/blackbox/common/DDSBlackboxTestsListeners.cpp +++ b/test/blackbox/common/DDSBlackboxTestsListeners.cpp @@ -3087,8 +3087,8 @@ TEST(DDSStatus, keyed_best_effort_on_unack_sample_removed) auto dummy_data = new KeyedHelloWorldPubSubType(); eprosima::fastdds::dds::InstanceHandle_t handle_odd; eprosima::fastdds::dds::InstanceHandle_t handle_even; - dummy_data->getKey(&data.front(), &handle_even); - dummy_data->getKey(&data.back(), &handle_odd); + dummy_data->compute_key(&data.front(), handle_even); + dummy_data->compute_key(&data.back(), handle_odd); reader.startReception(data); writer.send(data); @@ -3218,7 +3218,7 @@ TEST(DDSStatus, keyed_reliable_on_unack_sample_removed) auto dummy_data = new KeyedHelloWorldPubSubType(); eprosima::fastdds::dds::InstanceHandle_t handle; - dummy_data->getKey(&data.back(), &handle); + dummy_data->compute_key(&data.back(), handle); reader.startReception(data); // To avoid race condition receiving ACK, wait some time between samples @@ -3401,8 +3401,8 @@ TEST(DDSStatus, keyed_reliable_positive_acks_disabled_on_unack_sample_removed) auto dummy_data = new KeyedHelloWorldPubSubType(); eprosima::fastdds::dds::InstanceHandle_t handle_odd; eprosima::fastdds::dds::InstanceHandle_t handle_even; - dummy_data->getKey(&data.front(), &handle_even); - dummy_data->getKey(&data.back(), &handle_odd); + dummy_data->compute_key(&data.front(), handle_even); + dummy_data->compute_key(&data.back(), handle_odd); reader.startReception(data); diff --git a/test/blackbox/common/RTPSAsSocketReader.hpp b/test/blackbox/common/RTPSAsSocketReader.hpp index 8c54ac9b006..841aa8255c9 100644 --- a/test/blackbox/common/RTPSAsSocketReader.hpp +++ b/test/blackbox/common/RTPSAsSocketReader.hpp @@ -148,7 +148,7 @@ class RTPSAsSocketReader ASSERT_NE(participant_, nullptr); //Create readerhistory - hattr_.payloadMaxSize = 255 + type_.m_typeSize; + hattr_.payloadMaxSize = 255 + type_.max_serialized_type_size; history_ = new eprosima::fastdds::rtps::ReaderHistory(hattr_); ASSERT_NE(history_, nullptr); diff --git a/test/blackbox/common/RTPSAsSocketWriter.hpp b/test/blackbox/common/RTPSAsSocketWriter.hpp index 498478cc9e1..88dd861a11d 100644 --- a/test/blackbox/common/RTPSAsSocketWriter.hpp +++ b/test/blackbox/common/RTPSAsSocketWriter.hpp @@ -110,7 +110,7 @@ class RTPSAsSocketWriter : public eprosima::fastdds::rtps::WriterListener ASSERT_NE(participant_, nullptr); //Create writerhistory - hattr_.payloadMaxSize = 255 + type_.m_typeSize; + hattr_.payloadMaxSize = 255 + type_.max_serialized_type_size; history_ = new eprosima::fastdds::rtps::WriterHistory(hattr_); //Create writer diff --git a/test/blackbox/common/RTPSBlackboxTestsPools.cpp b/test/blackbox/common/RTPSBlackboxTestsPools.cpp index c5f74f6f2c0..b7a501e07e7 100644 --- a/test/blackbox/common/RTPSBlackboxTestsPools.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsPools.cpp @@ -236,7 +236,7 @@ void do_test( TType type_support; uint32_t num_samples = static_cast(data.size()); uint32_t num_endpoints = (uint32_t)pool_on_reader + (uint32_t)pool_on_writer; - uint32_t payload_size = static_cast(type_support.m_typeSize); + uint32_t payload_size = static_cast(type_support.max_serialized_type_size); payload_size += static_cast(eprosima::fastcdr::Cdr::alignment(payload_size, 4)); /* possible submessage alignment */ payload_size += 4u; // encapsulation header diff --git a/test/blackbox/common/RTPSWithRegistrationReader.hpp b/test/blackbox/common/RTPSWithRegistrationReader.hpp index 7a8ddc552f7..59c4f5553ca 100644 --- a/test/blackbox/common/RTPSWithRegistrationReader.hpp +++ b/test/blackbox/common/RTPSWithRegistrationReader.hpp @@ -140,7 +140,7 @@ class RTPSWithRegistrationReader , receiving_(false) , matched_(0) { - topic_attr_.topicDataType = type_.getName(); + topic_attr_.topicDataType = type_.get_name(); // Generate topic name std::ostringstream t; t << topic_name << "_" << asio::ip::host_name() << "_" << GET_PID(); @@ -172,7 +172,7 @@ class RTPSWithRegistrationReader } //Create readerhistory - hattr_.payloadMaxSize = type_.m_typeSize; + hattr_.payloadMaxSize = type_.max_serialized_type_size; history_ = new eprosima::fastdds::rtps::ReaderHistory(hattr_); ASSERT_NE(history_, nullptr); diff --git a/test/blackbox/common/RTPSWithRegistrationWriter.hpp b/test/blackbox/common/RTPSWithRegistrationWriter.hpp index 3bf71564e22..c926b5067ef 100644 --- a/test/blackbox/common/RTPSWithRegistrationWriter.hpp +++ b/test/blackbox/common/RTPSWithRegistrationWriter.hpp @@ -124,7 +124,7 @@ class RTPSWithRegistrationWriter , initialized_(false) , matched_(0) { - topic_attr_.topicDataType = type_.getName(); + topic_attr_.topicDataType = type_.get_name(); // Generate topic name std::ostringstream t; t << topic_name << "_" << asio::ip::host_name() << "_" << GET_PID(); @@ -159,7 +159,7 @@ class RTPSWithRegistrationWriter ASSERT_NE(participant_, nullptr); //Create writerhistory - hattr_.payloadMaxSize = type_.m_typeSize; + hattr_.payloadMaxSize = type_.max_serialized_type_size; if (has_payload_pool_) { history_ = new eprosima::fastdds::rtps::WriterHistory(hattr_, payload_pool_); diff --git a/test/blackbox/types/Data1mbPubSubTypes.cxx b/test/blackbox/types/Data1mbPubSubTypes.cxx index 3bda0762448..64eae932097 100644 --- a/test/blackbox/types/Data1mbPubSubTypes.cxx +++ b/test/blackbox/types/Data1mbPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; Data1mbPubSubType::Data1mbPubSubType() { - setName("Data1mb"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Data1mb::getMaxCdrSerializedSize()); -#else - Data1mb_max_cdr_typesize; -#endif + set_name("Data1mb"); + uint32_t type_size = Data1mb_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Data1mb_max_key_cdr_typesize > 16 ? Data1mb_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Data1mb_max_key_cdr_typesize > 16 ? Data1mb_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Data1mbPubSubType::~Data1mbPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Data1mbPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Data1mb* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool Data1mbPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Data1mbPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool Data1mbPubSubType::deserialize( Data1mb* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool Data1mbPubSubType::deserialize( return true; } -std::function Data1mbPubSubType::getSerializedSizeProvider( +uint32_t Data1mbPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* Data1mbPubSubType::createData() +void* Data1mbPubSubType::create_data() { return reinterpret_cast(new Data1mb()); } -void Data1mbPubSubType::deleteData( +void Data1mbPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool Data1mbPubSubType::getKey( +bool Data1mbPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Data1mb data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool Data1mbPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool Data1mbPubSubType::getKey( const Data1mb* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Data1mb_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Data1mb_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/Data1mbPubSubTypes.hpp b/test/blackbox/types/Data1mbPubSubTypes.hpp index b5e52335dc2..55c750a2eea 100644 --- a/test/blackbox/types/Data1mbPubSubTypes.hpp +++ b/test/blackbox/types/Data1mbPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "Data1mb.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated Data1mb is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class Data1mbPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class Data1mbPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class Data1mbPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/blackbox/types/Data64kbPubSubTypes.cxx b/test/blackbox/types/Data64kbPubSubTypes.cxx index 90a08fd6a58..020c3cfcd8b 100644 --- a/test/blackbox/types/Data64kbPubSubTypes.cxx +++ b/test/blackbox/types/Data64kbPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; Data64kbPubSubType::Data64kbPubSubType() { - setName("Data64kb"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Data64kb::getMaxCdrSerializedSize()); -#else - Data64kb_max_cdr_typesize; -#endif + set_name("Data64kb"); + uint32_t type_size = Data64kb_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Data64kb_max_key_cdr_typesize > 16 ? Data64kb_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Data64kb_max_key_cdr_typesize > 16 ? Data64kb_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Data64kbPubSubType::~Data64kbPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Data64kbPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Data64kb* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool Data64kbPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Data64kbPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool Data64kbPubSubType::deserialize( Data64kb* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool Data64kbPubSubType::deserialize( return true; } -std::function Data64kbPubSubType::getSerializedSizeProvider( +uint32_t Data64kbPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* Data64kbPubSubType::createData() +void* Data64kbPubSubType::create_data() { return reinterpret_cast(new Data64kb()); } -void Data64kbPubSubType::deleteData( +void Data64kbPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool Data64kbPubSubType::getKey( +bool Data64kbPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Data64kb data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool Data64kbPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool Data64kbPubSubType::getKey( const Data64kb* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Data64kb_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Data64kb_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/Data64kbPubSubTypes.hpp b/test/blackbox/types/Data64kbPubSubTypes.hpp index 9ec70bd190c..3be8206399d 100644 --- a/test/blackbox/types/Data64kbPubSubTypes.hpp +++ b/test/blackbox/types/Data64kbPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "Data64kb.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated Data64kb is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class Data64kbPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class Data64kbPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class Data64kbPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/blackbox/types/FixedSizedPubSubTypes.cxx b/test/blackbox/types/FixedSizedPubSubTypes.cxx index 545a7a8d600..27e8b1b3e70 100644 --- a/test/blackbox/types/FixedSizedPubSubTypes.cxx +++ b/test/blackbox/types/FixedSizedPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; FixedSizedPubSubType::FixedSizedPubSubType() { - setName("FixedSized"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FixedSized::getMaxCdrSerializedSize()); -#else - FixedSized_max_cdr_typesize; -#endif + set_name("FixedSized"); + uint32_t type_size = FixedSized_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FixedSized_max_key_cdr_typesize > 16 ? FixedSized_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FixedSized_max_key_cdr_typesize > 16 ? FixedSized_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FixedSizedPubSubType::~FixedSizedPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FixedSizedPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FixedSized* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool FixedSizedPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FixedSizedPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool FixedSizedPubSubType::deserialize( FixedSized* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool FixedSizedPubSubType::deserialize( return true; } -std::function FixedSizedPubSubType::getSerializedSizeProvider( +uint32_t FixedSizedPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* FixedSizedPubSubType::createData() +void* FixedSizedPubSubType::create_data() { return reinterpret_cast(new FixedSized()); } -void FixedSizedPubSubType::deleteData( +void FixedSizedPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FixedSizedPubSubType::getKey( +bool FixedSizedPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FixedSized data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FixedSizedPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool FixedSizedPubSubType::getKey( const FixedSized* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FixedSized_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FixedSized_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/FixedSizedPubSubTypes.hpp b/test/blackbox/types/FixedSizedPubSubTypes.hpp index b51c27393ab..95bf9d34c76 100644 --- a/test/blackbox/types/FixedSizedPubSubTypes.hpp +++ b/test/blackbox/types/FixedSizedPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "FixedSized.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated FixedSized is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER #ifndef SWIG @@ -87,38 +87,30 @@ class FixedSizedPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -133,10 +125,6 @@ class FixedSizedPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -163,11 +151,12 @@ class FixedSizedPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 2ULL == diff --git a/test/blackbox/types/HelloWorldPubSubTypes.cxx b/test/blackbox/types/HelloWorldPubSubTypes.cxx index fcd07be724a..7d87e77e533 100644 --- a/test/blackbox/types/HelloWorldPubSubTypes.cxx +++ b/test/blackbox/types/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() { - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), HelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/HelloWorldPubSubTypes.hpp b/test/blackbox/types/HelloWorldPubSubTypes.hpp index 75830b9c78b..8937b288ac5 100644 --- a/test/blackbox/types/HelloWorldPubSubTypes.hpp +++ b/test/blackbox/types/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/blackbox/types/KeyedData1mbPubSubTypes.cxx b/test/blackbox/types/KeyedData1mbPubSubTypes.cxx index 23aa6e4a424..8a4719cc30f 100644 --- a/test/blackbox/types/KeyedData1mbPubSubTypes.cxx +++ b/test/blackbox/types/KeyedData1mbPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; KeyedData1mbPubSubType::KeyedData1mbPubSubType() { - setName("KeyedData1mb"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedData1mb::getMaxCdrSerializedSize()); -#else - KeyedData1mb_max_cdr_typesize; -#endif + set_name("KeyedData1mb"); + uint32_t type_size = KeyedData1mb_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedData1mb_max_key_cdr_typesize > 16 ? KeyedData1mb_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedData1mb_max_key_cdr_typesize > 16 ? KeyedData1mb_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedData1mbPubSubType::~KeyedData1mbPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedData1mbPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedData1mb* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool KeyedData1mbPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedData1mbPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool KeyedData1mbPubSubType::deserialize( KeyedData1mb* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool KeyedData1mbPubSubType::deserialize( return true; } -std::function KeyedData1mbPubSubType::getSerializedSizeProvider( +uint32_t KeyedData1mbPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* KeyedData1mbPubSubType::createData() +void* KeyedData1mbPubSubType::create_data() { return reinterpret_cast(new KeyedData1mb()); } -void KeyedData1mbPubSubType::deleteData( +void KeyedData1mbPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedData1mbPubSubType::getKey( +bool KeyedData1mbPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedData1mb data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedData1mbPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool KeyedData1mbPubSubType::getKey( const KeyedData1mb* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedData1mb_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedData1mb_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/KeyedData1mbPubSubTypes.hpp b/test/blackbox/types/KeyedData1mbPubSubTypes.hpp index f351d1853db..cf2e1dc9c0c 100644 --- a/test/blackbox/types/KeyedData1mbPubSubTypes.hpp +++ b/test/blackbox/types/KeyedData1mbPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "KeyedData1mb.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated KeyedData1mb is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class KeyedData1mbPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class KeyedData1mbPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class KeyedData1mbPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/blackbox/types/KeyedHelloWorldPubSubTypes.cxx b/test/blackbox/types/KeyedHelloWorldPubSubTypes.cxx index 990b0adbca3..a2723597b50 100644 --- a/test/blackbox/types/KeyedHelloWorldPubSubTypes.cxx +++ b/test/blackbox/types/KeyedHelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; KeyedHelloWorldPubSubType::KeyedHelloWorldPubSubType() { - setName("KeyedHelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedHelloWorld::getMaxCdrSerializedSize()); -#else - KeyedHelloWorld_max_cdr_typesize; -#endif + set_name("KeyedHelloWorld"); + uint32_t type_size = KeyedHelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedHelloWorld_max_key_cdr_typesize > 16 ? KeyedHelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedHelloWorld_max_key_cdr_typesize > 16 ? KeyedHelloWorld_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedHelloWorldPubSubType::~KeyedHelloWorldPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedHelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool KeyedHelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedHelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool KeyedHelloWorldPubSubType::deserialize( KeyedHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool KeyedHelloWorldPubSubType::deserialize( return true; } -std::function KeyedHelloWorldPubSubType::getSerializedSizeProvider( +uint32_t KeyedHelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* KeyedHelloWorldPubSubType::createData() +void* KeyedHelloWorldPubSubType::create_data() { return reinterpret_cast(new KeyedHelloWorld()); } -void KeyedHelloWorldPubSubType::deleteData( +void KeyedHelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedHelloWorldPubSubType::getKey( +bool KeyedHelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedHelloWorld data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedHelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool KeyedHelloWorldPubSubType::getKey( const KeyedHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedHelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedHelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/KeyedHelloWorldPubSubTypes.hpp b/test/blackbox/types/KeyedHelloWorldPubSubTypes.hpp index 31c5b9bfd6b..481164a5a72 100644 --- a/test/blackbox/types/KeyedHelloWorldPubSubTypes.hpp +++ b/test/blackbox/types/KeyedHelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "KeyedHelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated KeyedHelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class KeyedHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class KeyedHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class KeyedHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/blackbox/types/StringTestPubSubTypes.cxx b/test/blackbox/types/StringTestPubSubTypes.cxx index f27379cc665..65c2f0b9d7e 100644 --- a/test/blackbox/types/StringTestPubSubTypes.cxx +++ b/test/blackbox/types/StringTestPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; StringTestPubSubType::StringTestPubSubType() { - setName("StringTest"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StringTest::getMaxCdrSerializedSize()); -#else - StringTest_max_cdr_typesize; -#endif + set_name("StringTest"); + uint32_t type_size = StringTest_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StringTest_max_key_cdr_typesize > 16 ? StringTest_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StringTest_max_key_cdr_typesize > 16 ? StringTest_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StringTestPubSubType::~StringTestPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StringTestPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StringTest* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool StringTestPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StringTestPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool StringTestPubSubType::deserialize( StringTest* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool StringTestPubSubType::deserialize( return true; } -std::function StringTestPubSubType::getSerializedSizeProvider( +uint32_t StringTestPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* StringTestPubSubType::createData() +void* StringTestPubSubType::create_data() { return reinterpret_cast(new StringTest()); } -void StringTestPubSubType::deleteData( +void StringTestPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StringTestPubSubType::getKey( +bool StringTestPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StringTest data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StringTestPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool StringTestPubSubType::getKey( const StringTest* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StringTest_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StringTest_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/StringTestPubSubTypes.hpp b/test/blackbox/types/StringTestPubSubTypes.hpp index 372d78eec85..1a391d45e8d 100644 --- a/test/blackbox/types/StringTestPubSubTypes.hpp +++ b/test/blackbox/types/StringTestPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "StringTest.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated StringTest is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class StringTestPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class StringTestPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class StringTestPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/blackbox/types/TestIncludeRegression3361PubSubTypes.hpp b/test/blackbox/types/TestIncludeRegression3361PubSubTypes.hpp index 480dd7051fb..6f4e7d9cbb8 100644 --- a/test/blackbox/types/TestIncludeRegression3361PubSubTypes.hpp +++ b/test/blackbox/types/TestIncludeRegression3361PubSubTypes.hpp @@ -32,10 +32,10 @@ #include "TestIncludeRegression3361.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated TestIncludeRegression3361 is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER namespace TestModule { diff --git a/test/blackbox/types/TestRegression3361PubSubTypes.cxx b/test/blackbox/types/TestRegression3361PubSubTypes.cxx index e62e4d81c84..27930170bab 100644 --- a/test/blackbox/types/TestRegression3361PubSubTypes.cxx +++ b/test/blackbox/types/TestRegression3361PubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; TestRegression3361PubSubType::TestRegression3361PubSubType() { - setName("TestRegression3361"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(TestRegression3361::getMaxCdrSerializedSize()); -#else - TestRegression3361_max_cdr_typesize; -#endif + set_name("TestRegression3361"); + uint32_t type_size = TestRegression3361_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = TestRegression3361_max_key_cdr_typesize > 16 ? TestRegression3361_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = TestRegression3361_max_key_cdr_typesize > 16 ? TestRegression3361_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } TestRegression3361PubSubType::~TestRegression3361PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool TestRegression3361PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const TestRegression3361* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool TestRegression3361PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool TestRegression3361PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool TestRegression3361PubSubType::deserialize( TestRegression3361* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool TestRegression3361PubSubType::deserialize( return true; } -std::function TestRegression3361PubSubType::getSerializedSizeProvider( +uint32_t TestRegression3361PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* TestRegression3361PubSubType::createData() +void* TestRegression3361PubSubType::create_data() { return reinterpret_cast(new TestRegression3361()); } -void TestRegression3361PubSubType::deleteData( +void TestRegression3361PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool TestRegression3361PubSubType::getKey( +bool TestRegression3361PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + TestRegression3361 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool TestRegression3361PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool TestRegression3361PubSubType::getKey( const TestRegression3361* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), TestRegression3361_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || TestRegression3361_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/TestRegression3361PubSubTypes.hpp b/test/blackbox/types/TestRegression3361PubSubTypes.hpp index b78d087acce..3f909155f76 100644 --- a/test/blackbox/types/TestRegression3361PubSubTypes.hpp +++ b/test/blackbox/types/TestRegression3361PubSubTypes.hpp @@ -33,10 +33,10 @@ #include "TestIncludeRegression3361PubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated TestRegression3361 is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class TestRegression3361PubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class TestRegression3361PubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class TestRegression3361PubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/blackbox/types/UnboundedHelloWorldPubSubTypes.cxx b/test/blackbox/types/UnboundedHelloWorldPubSubTypes.cxx index 0aa09725928..df87a981ec2 100644 --- a/test/blackbox/types/UnboundedHelloWorldPubSubTypes.cxx +++ b/test/blackbox/types/UnboundedHelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; UnboundedHelloWorldPubSubType::UnboundedHelloWorldPubSubType() { - setName("UnboundedHelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnboundedHelloWorld::getMaxCdrSerializedSize()); -#else - UnboundedHelloWorld_max_cdr_typesize; -#endif + set_name("UnboundedHelloWorld"); + uint32_t type_size = UnboundedHelloWorld_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnboundedHelloWorld_max_key_cdr_typesize > 16 ? UnboundedHelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnboundedHelloWorld_max_key_cdr_typesize > 16 ? UnboundedHelloWorld_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnboundedHelloWorldPubSubType::~UnboundedHelloWorldPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnboundedHelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnboundedHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool UnboundedHelloWorldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnboundedHelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool UnboundedHelloWorldPubSubType::deserialize( UnboundedHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool UnboundedHelloWorldPubSubType::deserialize( return true; } -std::function UnboundedHelloWorldPubSubType::getSerializedSizeProvider( +uint32_t UnboundedHelloWorldPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* UnboundedHelloWorldPubSubType::createData() +void* UnboundedHelloWorldPubSubType::create_data() { return reinterpret_cast(new UnboundedHelloWorld()); } -void UnboundedHelloWorldPubSubType::deleteData( +void UnboundedHelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnboundedHelloWorldPubSubType::getKey( +bool UnboundedHelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnboundedHelloWorld data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnboundedHelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool UnboundedHelloWorldPubSubType::getKey( const UnboundedHelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnboundedHelloWorld_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnboundedHelloWorld_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/UnboundedHelloWorldPubSubTypes.hpp b/test/blackbox/types/UnboundedHelloWorldPubSubTypes.hpp index d190c95d4de..cfd44f55696 100644 --- a/test/blackbox/types/UnboundedHelloWorldPubSubTypes.hpp +++ b/test/blackbox/types/UnboundedHelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "UnboundedHelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated UnboundedHelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class UnboundedHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class UnboundedHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class UnboundedHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/blackbox/types/core/core_typesPubSubTypes.cxx b/test/blackbox/types/core/core_typesPubSubTypes.cxx index bb921ed43d2..06dadb79a39 100644 --- a/test/blackbox/types/core/core_typesPubSubTypes.cxx +++ b/test/blackbox/types/core/core_typesPubSubTypes.cxx @@ -38,49 +38,42 @@ namespace eprosima { namespace detail { EntityId_tPubSubType::EntityId_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::EntityId_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(EntityId_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_EntityId_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::EntityId_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_EntityId_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_EntityId_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_EntityId_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_EntityId_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_EntityId_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EntityId_tPubSubType::~EntityId_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EntityId_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EntityId_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -95,16 +88,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EntityId_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -113,18 +102,14 @@ namespace eprosima { EntityId_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -137,52 +122,62 @@ namespace eprosima { return true; } - std::function EntityId_tPubSubType::getSerializedSizeProvider( + uint32_t EntityId_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* EntityId_tPubSubType::createData() + 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* EntityId_tPubSubType::create_data() { return reinterpret_cast(new EntityId_t()); } - void EntityId_tPubSubType::deleteData( + void EntityId_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool EntityId_tPubSubType::getKey( + bool EntityId_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + EntityId_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool EntityId_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -190,35 +185,27 @@ namespace eprosima { const EntityId_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_EntityId_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_EntityId_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -231,49 +218,42 @@ namespace eprosima { ProtocolVersion_tPubSubType::ProtocolVersion_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::ProtocolVersion_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(ProtocolVersion_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_ProtocolVersion_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::ProtocolVersion_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_ProtocolVersion_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_ProtocolVersion_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_ProtocolVersion_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_ProtocolVersion_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_ProtocolVersion_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ProtocolVersion_tPubSubType::~ProtocolVersion_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ProtocolVersion_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ProtocolVersion_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -288,16 +268,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ProtocolVersion_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -306,18 +282,14 @@ namespace eprosima { ProtocolVersion_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -330,52 +302,62 @@ namespace eprosima { return true; } - std::function ProtocolVersion_tPubSubType::getSerializedSizeProvider( + uint32_t ProtocolVersion_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* ProtocolVersion_tPubSubType::createData() + 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* ProtocolVersion_tPubSubType::create_data() { return reinterpret_cast(new ProtocolVersion_t()); } - void ProtocolVersion_tPubSubType::deleteData( + void ProtocolVersion_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool ProtocolVersion_tPubSubType::getKey( + bool ProtocolVersion_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + ProtocolVersion_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool ProtocolVersion_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -383,35 +365,27 @@ namespace eprosima { const ProtocolVersion_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_ProtocolVersion_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_ProtocolVersion_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -424,49 +398,42 @@ namespace eprosima { VendorId_tPubSubType::VendorId_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::VendorId_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(VendorId_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_VendorId_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::VendorId_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_VendorId_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_VendorId_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_VendorId_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_VendorId_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_VendorId_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } VendorId_tPubSubType::~VendorId_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool VendorId_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const VendorId_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -481,16 +448,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool VendorId_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -499,18 +462,14 @@ namespace eprosima { VendorId_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -523,52 +482,62 @@ namespace eprosima { return true; } - std::function VendorId_tPubSubType::getSerializedSizeProvider( + uint32_t VendorId_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* VendorId_tPubSubType::createData() + 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* VendorId_tPubSubType::create_data() { return reinterpret_cast(new VendorId_t()); } - void VendorId_tPubSubType::deleteData( + void VendorId_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool VendorId_tPubSubType::getKey( + bool VendorId_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + VendorId_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool VendorId_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -576,35 +545,27 @@ namespace eprosima { const VendorId_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_VendorId_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_VendorId_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -617,49 +578,42 @@ namespace eprosima { GuidPrefix_tPubSubType::GuidPrefix_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::GuidPrefix_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(GuidPrefix_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_GuidPrefix_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::GuidPrefix_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_GuidPrefix_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_GuidPrefix_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_GuidPrefix_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_GuidPrefix_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_GuidPrefix_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } GuidPrefix_tPubSubType::~GuidPrefix_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool GuidPrefix_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const GuidPrefix_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -674,16 +628,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool GuidPrefix_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -692,18 +642,14 @@ namespace eprosima { GuidPrefix_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -716,52 +662,62 @@ namespace eprosima { return true; } - std::function GuidPrefix_tPubSubType::getSerializedSizeProvider( + uint32_t GuidPrefix_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* GuidPrefix_tPubSubType::createData() + 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* GuidPrefix_tPubSubType::create_data() { return reinterpret_cast(new GuidPrefix_t()); } - void GuidPrefix_tPubSubType::deleteData( + void GuidPrefix_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool GuidPrefix_tPubSubType::getKey( + bool GuidPrefix_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + GuidPrefix_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool GuidPrefix_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -769,35 +725,27 @@ namespace eprosima { const GuidPrefix_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_GuidPrefix_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_GuidPrefix_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -810,49 +758,42 @@ namespace eprosima { GUID_tPubSubType::GUID_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::GUID_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(GUID_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_GUID_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::GUID_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_GUID_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_GUID_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_GUID_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_GUID_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_GUID_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } GUID_tPubSubType::~GUID_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool GUID_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const GUID_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -867,16 +808,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool GUID_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -885,18 +822,14 @@ namespace eprosima { GUID_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -909,52 +842,62 @@ namespace eprosima { return true; } - std::function GUID_tPubSubType::getSerializedSizeProvider( + uint32_t GUID_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* GUID_tPubSubType::createData() + 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* GUID_tPubSubType::create_data() { return reinterpret_cast(new GUID_t()); } - void GUID_tPubSubType::deleteData( + void GUID_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool GUID_tPubSubType::getKey( + bool GUID_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + GUID_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool GUID_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -962,35 +905,27 @@ namespace eprosima { const GUID_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_GUID_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_GUID_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1003,49 +938,42 @@ namespace eprosima { SequenceNumber_tPubSubType::SequenceNumber_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::SequenceNumber_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceNumber_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_SequenceNumber_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::SequenceNumber_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_SequenceNumber_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_SequenceNumber_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_SequenceNumber_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_SequenceNumber_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_SequenceNumber_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceNumber_tPubSubType::~SequenceNumber_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceNumber_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceNumber_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1060,16 +988,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceNumber_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1078,18 +1002,14 @@ namespace eprosima { SequenceNumber_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1102,52 +1022,62 @@ namespace eprosima { return true; } - std::function SequenceNumber_tPubSubType::getSerializedSizeProvider( + uint32_t SequenceNumber_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* SequenceNumber_tPubSubType::createData() + 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* SequenceNumber_tPubSubType::create_data() { return reinterpret_cast(new SequenceNumber_t()); } - void SequenceNumber_tPubSubType::deleteData( + void SequenceNumber_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool SequenceNumber_tPubSubType::getKey( + bool SequenceNumber_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + SequenceNumber_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool SequenceNumber_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1155,35 +1085,27 @@ namespace eprosima { const SequenceNumber_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_SequenceNumber_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_SequenceNumber_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1196,49 +1118,42 @@ namespace eprosima { Count_tPubSubType::Count_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::Count_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Count_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_Count_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::Count_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_Count_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_Count_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_Count_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_Count_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_Count_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Count_tPubSubType::~Count_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Count_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Count_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1253,16 +1168,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Count_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1271,18 +1182,14 @@ namespace eprosima { Count_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1295,52 +1202,62 @@ namespace eprosima { return true; } - std::function Count_tPubSubType::getSerializedSizeProvider( + uint32_t Count_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Count_tPubSubType::createData() + 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* Count_tPubSubType::create_data() { return reinterpret_cast(new Count_t()); } - void Count_tPubSubType::deleteData( + void Count_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Count_tPubSubType::getKey( + bool Count_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Count_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Count_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1348,35 +1265,27 @@ namespace eprosima { const Count_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_Count_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_Count_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1389,49 +1298,42 @@ namespace eprosima { Time_tPubSubType::Time_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::Time_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Time_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_Time_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::Time_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_Time_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_Time_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_Time_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_Time_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_Time_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Time_tPubSubType::~Time_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Time_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Time_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1446,16 +1348,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Time_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1464,18 +1362,14 @@ namespace eprosima { Time_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1488,52 +1382,62 @@ namespace eprosima { return true; } - std::function Time_tPubSubType::getSerializedSizeProvider( + uint32_t Time_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Time_tPubSubType::createData() + 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* Time_tPubSubType::create_data() { return reinterpret_cast(new Time_t()); } - void Time_tPubSubType::deleteData( + void Time_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Time_tPubSubType::getKey( + bool Time_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Time_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Time_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1541,35 +1445,27 @@ namespace eprosima { const Time_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_Time_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_Time_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1583,49 +1479,42 @@ namespace eprosima { SequenceNumberSetPubSubType::SequenceNumberSetPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::SequenceNumberSet"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceNumberSet::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_SequenceNumberSet_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::SequenceNumberSet"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_SequenceNumberSet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_SequenceNumberSet_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_SequenceNumberSet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_SequenceNumberSet_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_SequenceNumberSet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceNumberSetPubSubType::~SequenceNumberSetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceNumberSetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceNumberSet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1640,16 +1529,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceNumberSetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1658,18 +1543,14 @@ namespace eprosima { SequenceNumberSet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1682,52 +1563,62 @@ namespace eprosima { return true; } - std::function SequenceNumberSetPubSubType::getSerializedSizeProvider( + uint32_t SequenceNumberSetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* SequenceNumberSetPubSubType::createData() + 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* SequenceNumberSetPubSubType::create_data() { return reinterpret_cast(new SequenceNumberSet()); } - void SequenceNumberSetPubSubType::deleteData( + void SequenceNumberSetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool SequenceNumberSetPubSubType::getKey( + bool SequenceNumberSetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + SequenceNumberSet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool SequenceNumberSetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1735,35 +1626,27 @@ namespace eprosima { const SequenceNumberSet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_SequenceNumberSet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_SequenceNumberSet_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1776,49 +1659,42 @@ namespace eprosima { Locator_tPubSubType::Locator_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::Locator_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Locator_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_Locator_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::Locator_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_Locator_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_Locator_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_Locator_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_Locator_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_Locator_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Locator_tPubSubType::~Locator_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Locator_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Locator_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1833,16 +1709,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Locator_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1851,18 +1723,14 @@ namespace eprosima { Locator_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1875,52 +1743,62 @@ namespace eprosima { return true; } - std::function Locator_tPubSubType::getSerializedSizeProvider( + uint32_t Locator_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Locator_tPubSubType::createData() + 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* Locator_tPubSubType::create_data() { return reinterpret_cast(new Locator_t()); } - void Locator_tPubSubType::deleteData( + void Locator_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Locator_tPubSubType::getKey( + bool Locator_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Locator_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Locator_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1928,35 +1806,27 @@ namespace eprosima { const Locator_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_Locator_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_Locator_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1969,49 +1839,42 @@ namespace eprosima { Duration_tPubSubType::Duration_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::Duration_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Duration_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_Duration_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::Duration_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_Duration_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_Duration_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_Duration_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_Duration_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_Duration_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Duration_tPubSubType::~Duration_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Duration_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Duration_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2026,16 +1889,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Duration_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2044,18 +1903,14 @@ namespace eprosima { Duration_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2068,52 +1923,62 @@ namespace eprosima { return true; } - std::function Duration_tPubSubType::getSerializedSizeProvider( + uint32_t Duration_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Duration_tPubSubType::createData() + 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* Duration_tPubSubType::create_data() { return reinterpret_cast(new Duration_t()); } - void Duration_tPubSubType::deleteData( + void Duration_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Duration_tPubSubType::getKey( + bool Duration_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Duration_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Duration_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2121,35 +1986,27 @@ namespace eprosima { const Duration_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_Duration_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_Duration_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2164,49 +2021,42 @@ namespace eprosima { StatusInfo_tPubSubType::StatusInfo_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::StatusInfo_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(StatusInfo_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_StatusInfo_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::StatusInfo_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_StatusInfo_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_StatusInfo_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_StatusInfo_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_StatusInfo_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_StatusInfo_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StatusInfo_tPubSubType::~StatusInfo_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StatusInfo_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StatusInfo_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2221,16 +2071,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StatusInfo_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2239,18 +2085,14 @@ namespace eprosima { StatusInfo_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2263,52 +2105,62 @@ namespace eprosima { return true; } - std::function StatusInfo_tPubSubType::getSerializedSizeProvider( + uint32_t StatusInfo_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* StatusInfo_tPubSubType::createData() + 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* StatusInfo_tPubSubType::create_data() { return reinterpret_cast(new StatusInfo_t()); } - void StatusInfo_tPubSubType::deleteData( + void StatusInfo_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool StatusInfo_tPubSubType::getKey( + bool StatusInfo_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + StatusInfo_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool StatusInfo_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2316,35 +2168,27 @@ namespace eprosima { const StatusInfo_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_StatusInfo_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_StatusInfo_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2357,49 +2201,42 @@ namespace eprosima { KeyHash_tPubSubType::KeyHash_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::KeyHash_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyHash_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_KeyHash_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::KeyHash_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_KeyHash_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_KeyHash_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_KeyHash_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_KeyHash_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_KeyHash_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyHash_tPubSubType::~KeyHash_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyHash_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyHash_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2414,16 +2251,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyHash_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2432,18 +2265,14 @@ namespace eprosima { KeyHash_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2456,52 +2285,62 @@ namespace eprosima { return true; } - std::function KeyHash_tPubSubType::getSerializedSizeProvider( + uint32_t KeyHash_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* KeyHash_tPubSubType::createData() + 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* KeyHash_tPubSubType::create_data() { return reinterpret_cast(new KeyHash_t()); } - void KeyHash_tPubSubType::deleteData( + void KeyHash_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool KeyHash_tPubSubType::getKey( + bool KeyHash_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + KeyHash_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool KeyHash_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2509,35 +2348,27 @@ namespace eprosima { const KeyHash_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_KeyHash_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_KeyHash_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2550,49 +2381,42 @@ namespace eprosima { EntityName_tPubSubType::EntityName_tPubSubType() { - setName("eprosima::fastdds::rtps::core::detail::EntityName_t"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(EntityName_t::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_detail_EntityName_t_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::detail::EntityName_t"); + uint32_t type_size = eprosima_fastdds_rtps_core_detail_EntityName_t_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_detail_EntityName_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_EntityName_t_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_detail_EntityName_t_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_detail_EntityName_t_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EntityName_tPubSubType::~EntityName_tPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EntityName_tPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EntityName_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2607,16 +2431,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EntityName_tPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2625,18 +2445,14 @@ namespace eprosima { EntityName_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2649,52 +2465,62 @@ namespace eprosima { return true; } - std::function EntityName_tPubSubType::getSerializedSizeProvider( + uint32_t EntityName_tPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* EntityName_tPubSubType::createData() + 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* EntityName_tPubSubType::create_data() { return reinterpret_cast(new EntityName_t()); } - void EntityName_tPubSubType::deleteData( + void EntityName_tPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool EntityName_tPubSubType::getKey( + bool EntityName_tPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + EntityName_t data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool EntityName_tPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2702,35 +2528,27 @@ namespace eprosima { const EntityName_t* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_detail_EntityName_t_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_detail_EntityName_t_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2745,49 +2563,42 @@ namespace eprosima { HeaderPubSubType::HeaderPubSubType() { - setName("eprosima::fastdds::rtps::core::Header"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Header::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_Header_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::Header"); + uint32_t type_size = eprosima_fastdds_rtps_core_Header_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_Header_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_Header_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_Header_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_Header_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } HeaderPubSubType::~HeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Header* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2802,16 +2613,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2820,18 +2627,14 @@ namespace eprosima { Header* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2844,52 +2647,62 @@ namespace eprosima { return true; } - std::function HeaderPubSubType::getSerializedSizeProvider( + uint32_t HeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HeaderPubSubType::createData() + void* HeaderPubSubType::create_data() { return reinterpret_cast(new Header()); } - void HeaderPubSubType::deleteData( + void HeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool HeaderPubSubType::getKey( + bool HeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Header data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool HeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2897,35 +2710,27 @@ namespace eprosima { const Header* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_Header_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_Header_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2938,49 +2743,42 @@ namespace eprosima { SubmessageHeaderPubSubType::SubmessageHeaderPubSubType() { - setName("eprosima::fastdds::rtps::core::SubmessageHeader"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(SubmessageHeader::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_SubmessageHeader_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::SubmessageHeader"); + uint32_t type_size = eprosima_fastdds_rtps_core_SubmessageHeader_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_SubmessageHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_SubmessageHeader_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_SubmessageHeader_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_SubmessageHeader_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SubmessageHeaderPubSubType::~SubmessageHeaderPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SubmessageHeaderPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SubmessageHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2995,16 +2793,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SubmessageHeaderPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3013,18 +2807,14 @@ namespace eprosima { SubmessageHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3037,52 +2827,62 @@ namespace eprosima { return true; } - std::function SubmessageHeaderPubSubType::getSerializedSizeProvider( + uint32_t SubmessageHeaderPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* SubmessageHeaderPubSubType::createData() + void* SubmessageHeaderPubSubType::create_data() { return reinterpret_cast(new SubmessageHeader()); } - void SubmessageHeaderPubSubType::deleteData( + void SubmessageHeaderPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool SubmessageHeaderPubSubType::getKey( + bool SubmessageHeaderPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + SubmessageHeader data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool SubmessageHeaderPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3090,35 +2890,27 @@ namespace eprosima { const SubmessageHeader* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_SubmessageHeader_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_SubmessageHeader_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3134,49 +2926,42 @@ namespace eprosima { AckNackSubmessagePubSubType::AckNackSubmessagePubSubType() { - setName("eprosima::fastdds::rtps::core::AckNackSubmessage"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(AckNackSubmessage::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_AckNackSubmessage_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::AckNackSubmessage"); + uint32_t type_size = eprosima_fastdds_rtps_core_AckNackSubmessage_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_AckNackSubmessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_AckNackSubmessage_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_AckNackSubmessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_AckNackSubmessage_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AckNackSubmessagePubSubType::~AckNackSubmessagePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AckNackSubmessagePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AckNackSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3191,16 +2976,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AckNackSubmessagePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3209,18 +2990,14 @@ namespace eprosima { AckNackSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3233,52 +3010,62 @@ namespace eprosima { return true; } - std::function AckNackSubmessagePubSubType::getSerializedSizeProvider( + uint32_t AckNackSubmessagePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* AckNackSubmessagePubSubType::createData() + void* AckNackSubmessagePubSubType::create_data() { return reinterpret_cast(new AckNackSubmessage()); } - void AckNackSubmessagePubSubType::deleteData( + void AckNackSubmessagePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool AckNackSubmessagePubSubType::getKey( + bool AckNackSubmessagePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + AckNackSubmessage data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool AckNackSubmessagePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3286,35 +3073,27 @@ namespace eprosima { const AckNackSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_AckNackSubmessage_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_AckNackSubmessage_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3327,49 +3106,42 @@ namespace eprosima { HeartBeatSubmessagePubSubType::HeartBeatSubmessagePubSubType() { - setName("eprosima::fastdds::rtps::core::HeartBeatSubmessage"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(HeartBeatSubmessage::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_HeartBeatSubmessage_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::HeartBeatSubmessage"); + uint32_t type_size = eprosima_fastdds_rtps_core_HeartBeatSubmessage_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_HeartBeatSubmessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_HeartBeatSubmessage_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_HeartBeatSubmessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_HeartBeatSubmessage_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } HeartBeatSubmessagePubSubType::~HeartBeatSubmessagePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HeartBeatSubmessagePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HeartBeatSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3384,16 +3156,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HeartBeatSubmessagePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3402,18 +3170,14 @@ namespace eprosima { HeartBeatSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3426,52 +3190,62 @@ namespace eprosima { return true; } - std::function HeartBeatSubmessagePubSubType::getSerializedSizeProvider( + uint32_t HeartBeatSubmessagePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* HeartBeatSubmessagePubSubType::createData() + void* HeartBeatSubmessagePubSubType::create_data() { return reinterpret_cast(new HeartBeatSubmessage()); } - void HeartBeatSubmessagePubSubType::deleteData( + void HeartBeatSubmessagePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool HeartBeatSubmessagePubSubType::getKey( + bool HeartBeatSubmessagePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + HeartBeatSubmessage data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool HeartBeatSubmessagePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3479,35 +3253,27 @@ namespace eprosima { const HeartBeatSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_HeartBeatSubmessage_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_HeartBeatSubmessage_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3520,49 +3286,42 @@ namespace eprosima { InfoDestinationSubmessagePubSubType::InfoDestinationSubmessagePubSubType() { - setName("eprosima::fastdds::rtps::core::InfoDestinationSubmessage"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(InfoDestinationSubmessage::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_InfoDestinationSubmessage_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::InfoDestinationSubmessage"); + uint32_t type_size = eprosima_fastdds_rtps_core_InfoDestinationSubmessage_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_InfoDestinationSubmessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_InfoDestinationSubmessage_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_InfoDestinationSubmessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_InfoDestinationSubmessage_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InfoDestinationSubmessagePubSubType::~InfoDestinationSubmessagePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InfoDestinationSubmessagePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InfoDestinationSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3577,16 +3336,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InfoDestinationSubmessagePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3595,18 +3350,14 @@ namespace eprosima { InfoDestinationSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3619,52 +3370,62 @@ namespace eprosima { return true; } - std::function InfoDestinationSubmessagePubSubType::getSerializedSizeProvider( + uint32_t InfoDestinationSubmessagePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* InfoDestinationSubmessagePubSubType::createData() + void* InfoDestinationSubmessagePubSubType::create_data() { return reinterpret_cast(new InfoDestinationSubmessage()); } - void InfoDestinationSubmessagePubSubType::deleteData( + void InfoDestinationSubmessagePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool InfoDestinationSubmessagePubSubType::getKey( + bool InfoDestinationSubmessagePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + InfoDestinationSubmessage data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool InfoDestinationSubmessagePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3672,35 +3433,27 @@ namespace eprosima { const InfoDestinationSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_InfoDestinationSubmessage_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_InfoDestinationSubmessage_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3713,49 +3466,42 @@ namespace eprosima { InfoSourceSubmessagePubSubType::InfoSourceSubmessagePubSubType() { - setName("eprosima::fastdds::rtps::core::InfoSourceSubmessage"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(InfoSourceSubmessage::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_InfoSourceSubmessage_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::InfoSourceSubmessage"); + uint32_t type_size = eprosima_fastdds_rtps_core_InfoSourceSubmessage_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_InfoSourceSubmessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_InfoSourceSubmessage_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_InfoSourceSubmessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_InfoSourceSubmessage_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InfoSourceSubmessagePubSubType::~InfoSourceSubmessagePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InfoSourceSubmessagePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InfoSourceSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3770,16 +3516,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InfoSourceSubmessagePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3788,18 +3530,14 @@ namespace eprosima { InfoSourceSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3812,52 +3550,62 @@ namespace eprosima { return true; } - std::function InfoSourceSubmessagePubSubType::getSerializedSizeProvider( + uint32_t InfoSourceSubmessagePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* InfoSourceSubmessagePubSubType::createData() + void* InfoSourceSubmessagePubSubType::create_data() { return reinterpret_cast(new InfoSourceSubmessage()); } - void InfoSourceSubmessagePubSubType::deleteData( + void InfoSourceSubmessagePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool InfoSourceSubmessagePubSubType::getKey( + bool InfoSourceSubmessagePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + InfoSourceSubmessage data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool InfoSourceSubmessagePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3865,35 +3613,27 @@ namespace eprosima { const InfoSourceSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_InfoSourceSubmessage_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_InfoSourceSubmessage_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3906,49 +3646,42 @@ namespace eprosima { InfoTimestampSubmessagePubSubType::InfoTimestampSubmessagePubSubType() { - setName("eprosima::fastdds::rtps::core::InfoTimestampSubmessage"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(InfoTimestampSubmessage::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_InfoTimestampSubmessage_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::InfoTimestampSubmessage"); + uint32_t type_size = eprosima_fastdds_rtps_core_InfoTimestampSubmessage_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_InfoTimestampSubmessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_InfoTimestampSubmessage_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_InfoTimestampSubmessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_InfoTimestampSubmessage_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InfoTimestampSubmessagePubSubType::~InfoTimestampSubmessagePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InfoTimestampSubmessagePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InfoTimestampSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3963,16 +3696,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InfoTimestampSubmessagePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3981,18 +3710,14 @@ namespace eprosima { InfoTimestampSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4005,52 +3730,62 @@ namespace eprosima { return true; } - std::function InfoTimestampSubmessagePubSubType::getSerializedSizeProvider( + uint32_t InfoTimestampSubmessagePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* InfoTimestampSubmessagePubSubType::createData() + void* InfoTimestampSubmessagePubSubType::create_data() { return reinterpret_cast(new InfoTimestampSubmessage()); } - void InfoTimestampSubmessagePubSubType::deleteData( + void InfoTimestampSubmessagePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool InfoTimestampSubmessagePubSubType::getKey( + bool InfoTimestampSubmessagePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + InfoTimestampSubmessage data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool InfoTimestampSubmessagePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4058,35 +3793,27 @@ namespace eprosima { const InfoTimestampSubmessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_InfoTimestampSubmessage_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_InfoTimestampSubmessage_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4100,49 +3827,42 @@ namespace eprosima { RTPSMessagePubSubType::RTPSMessagePubSubType() { - setName("eprosima::fastdds::rtps::core::RTPSMessage"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(RTPSMessage::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_rtps_core_RTPSMessage_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::rtps::core::RTPSMessage"); + uint32_t type_size = eprosima_fastdds_rtps_core_RTPSMessage_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_rtps_core_RTPSMessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_RTPSMessage_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_rtps_core_RTPSMessage_max_key_cdr_typesize > 16 ? eprosima_fastdds_rtps_core_RTPSMessage_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } RTPSMessagePubSubType::~RTPSMessagePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool RTPSMessagePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const RTPSMessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4157,16 +3877,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool RTPSMessagePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4175,18 +3891,14 @@ namespace eprosima { RTPSMessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4199,52 +3911,62 @@ namespace eprosima { return true; } - std::function RTPSMessagePubSubType::getSerializedSizeProvider( + uint32_t RTPSMessagePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* RTPSMessagePubSubType::createData() + void* RTPSMessagePubSubType::create_data() { return reinterpret_cast(new RTPSMessage()); } - void RTPSMessagePubSubType::deleteData( + void RTPSMessagePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool RTPSMessagePubSubType::getKey( + bool RTPSMessagePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + RTPSMessage data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool RTPSMessagePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4252,35 +3974,27 @@ namespace eprosima { const RTPSMessage* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_rtps_core_RTPSMessage_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_rtps_core_RTPSMessage_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/core/core_typesPubSubTypes.hpp b/test/blackbox/types/core/core_typesPubSubTypes.hpp index 72f426d79aa..10945b7926a 100644 --- a/test/blackbox/types/core/core_typesPubSubTypes.hpp +++ b/test/blackbox/types/core/core_typesPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "core_types.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated core_types is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER namespace eprosima { @@ -64,38 +64,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -110,10 +102,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -134,8 +122,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -155,38 +145,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -201,10 +183,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -225,8 +203,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -246,38 +226,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -292,10 +264,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -316,8 +284,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -337,38 +307,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -383,10 +345,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -407,8 +365,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -428,38 +388,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -474,10 +426,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -498,8 +446,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -519,38 +469,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -565,10 +507,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -589,8 +527,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -610,38 +550,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -656,10 +588,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -680,8 +608,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -701,38 +631,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -747,10 +669,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -771,8 +689,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef eprosima::fastdds::rtps::core::detail::Time_t Timestamp; @@ -793,38 +713,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -839,10 +751,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -863,8 +771,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -884,38 +794,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -930,10 +832,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -954,8 +852,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -975,38 +875,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1021,10 +913,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1045,8 +933,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef uint32_t DomainId_t; @@ -1068,38 +958,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1114,10 +996,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1138,8 +1016,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1159,38 +1039,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1205,10 +1077,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1229,8 +1097,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1250,38 +1120,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1296,10 +1158,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1320,8 +1178,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace detail @@ -1342,38 +1202,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1388,10 +1240,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1412,8 +1260,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1433,38 +1283,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1479,10 +1321,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1503,8 +1341,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; namespace SubmessageKind @@ -1527,38 +1367,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1573,10 +1405,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1597,8 +1425,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1618,38 +1448,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1664,10 +1486,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1688,8 +1506,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1709,38 +1529,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1755,10 +1567,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1779,8 +1587,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1800,38 +1610,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1846,10 +1648,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1870,8 +1668,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1891,38 +1691,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1937,10 +1729,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1961,8 +1749,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1983,38 +1773,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2029,10 +1811,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2053,8 +1831,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace core diff --git a/test/blackbox/types/statistics/monitorservice_typesPubSubTypes.cxx b/test/blackbox/types/statistics/monitorservice_typesPubSubTypes.cxx index d0e23ab6f51..7918dca6ede 100644 --- a/test/blackbox/types/statistics/monitorservice_typesPubSubTypes.cxx +++ b/test/blackbox/types/statistics/monitorservice_typesPubSubTypes.cxx @@ -36,49 +36,42 @@ namespace eprosima { namespace statistics { ConnectionPubSubType::ConnectionPubSubType() { - setName("eprosima::fastdds::statistics::Connection"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Connection::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_Connection_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::Connection"); + uint32_t type_size = eprosima_fastdds_statistics_Connection_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_Connection_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Connection_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_Connection_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Connection_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ConnectionPubSubType::~ConnectionPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ConnectionPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Connection* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -93,16 +86,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ConnectionPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -111,18 +100,14 @@ namespace eprosima { Connection* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -135,52 +120,62 @@ namespace eprosima { return true; } - std::function ConnectionPubSubType::getSerializedSizeProvider( + uint32_t ConnectionPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* ConnectionPubSubType::createData() + 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* ConnectionPubSubType::create_data() { return reinterpret_cast(new Connection()); } - void ConnectionPubSubType::deleteData( + void ConnectionPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool ConnectionPubSubType::getKey( + bool ConnectionPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Connection data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool ConnectionPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -188,35 +183,27 @@ namespace eprosima { const Connection* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_Connection_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_Connection_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -229,49 +216,42 @@ namespace eprosima { QosPolicyCount_sPubSubType::QosPolicyCount_sPubSubType() { - setName("eprosima::fastdds::statistics::QosPolicyCount_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(QosPolicyCount_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_QosPolicyCount_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::QosPolicyCount_s"); + uint32_t type_size = eprosima_fastdds_statistics_QosPolicyCount_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } QosPolicyCount_sPubSubType::~QosPolicyCount_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool QosPolicyCount_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const QosPolicyCount_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -286,16 +266,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool QosPolicyCount_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -304,18 +280,14 @@ namespace eprosima { QosPolicyCount_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -328,52 +300,62 @@ namespace eprosima { return true; } - std::function QosPolicyCount_sPubSubType::getSerializedSizeProvider( + uint32_t QosPolicyCount_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* QosPolicyCount_sPubSubType::createData() + 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* QosPolicyCount_sPubSubType::create_data() { return reinterpret_cast(new QosPolicyCount_s()); } - void QosPolicyCount_sPubSubType::deleteData( + void QosPolicyCount_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool QosPolicyCount_sPubSubType::getKey( + bool QosPolicyCount_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + QosPolicyCount_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool QosPolicyCount_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -381,35 +363,27 @@ namespace eprosima { const QosPolicyCount_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_QosPolicyCount_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -422,49 +396,42 @@ namespace eprosima { BaseStatus_sPubSubType::BaseStatus_sPubSubType() { - setName("eprosima::fastdds::statistics::BaseStatus_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(BaseStatus_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_BaseStatus_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::BaseStatus_s"); + uint32_t type_size = eprosima_fastdds_statistics_BaseStatus_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BaseStatus_sPubSubType::~BaseStatus_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BaseStatus_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BaseStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -479,16 +446,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BaseStatus_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -497,18 +460,14 @@ namespace eprosima { BaseStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -521,52 +480,62 @@ namespace eprosima { return true; } - std::function BaseStatus_sPubSubType::getSerializedSizeProvider( + uint32_t BaseStatus_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* BaseStatus_sPubSubType::createData() + 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* BaseStatus_sPubSubType::create_data() { return reinterpret_cast(new BaseStatus_s()); } - void BaseStatus_sPubSubType::deleteData( + void BaseStatus_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool BaseStatus_sPubSubType::getKey( + bool BaseStatus_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + BaseStatus_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool BaseStatus_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -574,35 +543,27 @@ namespace eprosima { const BaseStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_BaseStatus_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -616,49 +577,42 @@ namespace eprosima { IncompatibleQoSStatus_sPubSubType::IncompatibleQoSStatus_sPubSubType() { - setName("eprosima::fastdds::statistics::IncompatibleQoSStatus_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(IncompatibleQoSStatus_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::IncompatibleQoSStatus_s"); + uint32_t type_size = eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } IncompatibleQoSStatus_sPubSubType::~IncompatibleQoSStatus_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool IncompatibleQoSStatus_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const IncompatibleQoSStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -673,16 +627,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool IncompatibleQoSStatus_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -691,18 +641,14 @@ namespace eprosima { IncompatibleQoSStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -715,52 +661,62 @@ namespace eprosima { return true; } - std::function IncompatibleQoSStatus_sPubSubType::getSerializedSizeProvider( + uint32_t IncompatibleQoSStatus_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* IncompatibleQoSStatus_sPubSubType::createData() + 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* IncompatibleQoSStatus_sPubSubType::create_data() { return reinterpret_cast(new IncompatibleQoSStatus_s()); } - void IncompatibleQoSStatus_sPubSubType::deleteData( + void IncompatibleQoSStatus_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool IncompatibleQoSStatus_sPubSubType::getKey( + bool IncompatibleQoSStatus_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + IncompatibleQoSStatus_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool IncompatibleQoSStatus_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -768,35 +724,27 @@ namespace eprosima { const IncompatibleQoSStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_IncompatibleQoSStatus_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -809,49 +757,42 @@ namespace eprosima { LivelinessChangedStatus_sPubSubType::LivelinessChangedStatus_sPubSubType() { - setName("eprosima::fastdds::statistics::LivelinessChangedStatus_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(LivelinessChangedStatus_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::LivelinessChangedStatus_s"); + uint32_t type_size = eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } LivelinessChangedStatus_sPubSubType::~LivelinessChangedStatus_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool LivelinessChangedStatus_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const LivelinessChangedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -866,16 +807,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool LivelinessChangedStatus_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -884,18 +821,14 @@ namespace eprosima { LivelinessChangedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -908,52 +841,62 @@ namespace eprosima { return true; } - std::function LivelinessChangedStatus_sPubSubType::getSerializedSizeProvider( + uint32_t LivelinessChangedStatus_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* LivelinessChangedStatus_sPubSubType::createData() + 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* LivelinessChangedStatus_sPubSubType::create_data() { return reinterpret_cast(new LivelinessChangedStatus_s()); } - void LivelinessChangedStatus_sPubSubType::deleteData( + void LivelinessChangedStatus_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool LivelinessChangedStatus_sPubSubType::getKey( + bool LivelinessChangedStatus_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + LivelinessChangedStatus_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool LivelinessChangedStatus_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -961,35 +904,27 @@ namespace eprosima { const LivelinessChangedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_LivelinessChangedStatus_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1002,49 +937,42 @@ namespace eprosima { DeadlineMissedStatus_sPubSubType::DeadlineMissedStatus_sPubSubType() { - setName("eprosima::fastdds::statistics::DeadlineMissedStatus_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(DeadlineMissedStatus_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::DeadlineMissedStatus_s"); + uint32_t type_size = eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DeadlineMissedStatus_sPubSubType::~DeadlineMissedStatus_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DeadlineMissedStatus_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const DeadlineMissedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1059,16 +987,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DeadlineMissedStatus_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1077,18 +1001,14 @@ namespace eprosima { DeadlineMissedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1101,52 +1021,62 @@ namespace eprosima { return true; } - std::function DeadlineMissedStatus_sPubSubType::getSerializedSizeProvider( + uint32_t DeadlineMissedStatus_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* DeadlineMissedStatus_sPubSubType::createData() + 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* DeadlineMissedStatus_sPubSubType::create_data() { return reinterpret_cast(new DeadlineMissedStatus_s()); } - void DeadlineMissedStatus_sPubSubType::deleteData( + void DeadlineMissedStatus_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool DeadlineMissedStatus_sPubSubType::getKey( + bool DeadlineMissedStatus_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + DeadlineMissedStatus_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool DeadlineMissedStatus_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1154,35 +1084,27 @@ namespace eprosima { const DeadlineMissedStatus_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_DeadlineMissedStatus_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1202,49 +1124,42 @@ namespace eprosima { MonitorServiceStatusDataPubSubType::MonitorServiceStatusDataPubSubType() { - setName("eprosima::fastdds::statistics::MonitorServiceStatusData"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(MonitorServiceStatusData::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_MonitorServiceStatusData_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::MonitorServiceStatusData"); + uint32_t type_size = eprosima_fastdds_statistics_MonitorServiceStatusData_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MonitorServiceStatusDataPubSubType::~MonitorServiceStatusDataPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MonitorServiceStatusDataPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MonitorServiceStatusData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1259,16 +1174,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MonitorServiceStatusDataPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1277,18 +1188,14 @@ namespace eprosima { MonitorServiceStatusData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1301,52 +1208,62 @@ namespace eprosima { return true; } - std::function MonitorServiceStatusDataPubSubType::getSerializedSizeProvider( + uint32_t MonitorServiceStatusDataPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* MonitorServiceStatusDataPubSubType::createData() + 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* MonitorServiceStatusDataPubSubType::create_data() { return reinterpret_cast(new MonitorServiceStatusData()); } - void MonitorServiceStatusDataPubSubType::deleteData( + void MonitorServiceStatusDataPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool MonitorServiceStatusDataPubSubType::getKey( + bool MonitorServiceStatusDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + MonitorServiceStatusData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool MonitorServiceStatusDataPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1354,35 +1271,27 @@ namespace eprosima { const MonitorServiceStatusData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_MonitorServiceStatusData_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/statistics/monitorservice_typesPubSubTypes.hpp b/test/blackbox/types/statistics/monitorservice_typesPubSubTypes.hpp index 966a6a459c8..5c62a2bba76 100644 --- a/test/blackbox/types/statistics/monitorservice_typesPubSubTypes.hpp +++ b/test/blackbox/types/statistics/monitorservice_typesPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated monitorservice_types is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER namespace eprosima { @@ -61,38 +61,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -107,10 +99,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -131,8 +119,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -152,38 +142,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -198,10 +180,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -222,8 +200,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -243,38 +223,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -289,10 +261,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -313,8 +281,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef std::vector QosPolicyCountSeq_s; @@ -335,38 +305,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -381,10 +343,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -405,8 +363,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -426,38 +386,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -472,10 +424,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -496,8 +444,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -517,38 +467,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -563,10 +505,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -587,8 +525,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; typedef eprosima::fastdds::statistics::BaseStatus_s LivelinessLostStatus_s; @@ -625,38 +565,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -671,10 +603,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -695,8 +623,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace statistics diff --git a/test/blackbox/types/statistics/typesPubSubTypes.cxx b/test/blackbox/types/statistics/typesPubSubTypes.cxx index fbc16b14e72..f2ad0bcbf73 100644 --- a/test/blackbox/types/statistics/typesPubSubTypes.cxx +++ b/test/blackbox/types/statistics/typesPubSubTypes.cxx @@ -37,49 +37,42 @@ namespace eprosima { namespace detail { EntityId_sPubSubType::EntityId_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::EntityId_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(EntityId_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_EntityId_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::EntityId_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_EntityId_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EntityId_sPubSubType::~EntityId_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EntityId_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EntityId_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -94,16 +87,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EntityId_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -112,18 +101,14 @@ namespace eprosima { EntityId_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -136,52 +121,62 @@ namespace eprosima { return true; } - std::function EntityId_sPubSubType::getSerializedSizeProvider( + uint32_t EntityId_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* EntityId_sPubSubType::createData() + 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* EntityId_sPubSubType::create_data() { return reinterpret_cast(new EntityId_s()); } - void EntityId_sPubSubType::deleteData( + void EntityId_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool EntityId_sPubSubType::getKey( + bool EntityId_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + EntityId_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool EntityId_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -189,35 +184,27 @@ namespace eprosima { const EntityId_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_EntityId_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -230,49 +217,42 @@ namespace eprosima { GuidPrefix_sPubSubType::GuidPrefix_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::GuidPrefix_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(GuidPrefix_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_GuidPrefix_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::GuidPrefix_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_GuidPrefix_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } GuidPrefix_sPubSubType::~GuidPrefix_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool GuidPrefix_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const GuidPrefix_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -287,16 +267,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool GuidPrefix_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -305,18 +281,14 @@ namespace eprosima { GuidPrefix_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -329,52 +301,62 @@ namespace eprosima { return true; } - std::function GuidPrefix_sPubSubType::getSerializedSizeProvider( + uint32_t GuidPrefix_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* GuidPrefix_sPubSubType::createData() + 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* GuidPrefix_sPubSubType::create_data() { return reinterpret_cast(new GuidPrefix_s()); } - void GuidPrefix_sPubSubType::deleteData( + void GuidPrefix_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool GuidPrefix_sPubSubType::getKey( + bool GuidPrefix_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + GuidPrefix_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool GuidPrefix_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -382,35 +364,27 @@ namespace eprosima { const GuidPrefix_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_GuidPrefix_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -423,49 +397,42 @@ namespace eprosima { GUID_sPubSubType::GUID_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::GUID_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(GUID_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_GUID_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::GUID_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_GUID_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } GUID_sPubSubType::~GUID_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool GUID_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const GUID_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -480,16 +447,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool GUID_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -498,18 +461,14 @@ namespace eprosima { GUID_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -522,52 +481,62 @@ namespace eprosima { return true; } - std::function GUID_sPubSubType::getSerializedSizeProvider( + uint32_t GUID_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* GUID_sPubSubType::createData() + 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* GUID_sPubSubType::create_data() { return reinterpret_cast(new GUID_s()); } - void GUID_sPubSubType::deleteData( + void GUID_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool GUID_sPubSubType::getKey( + bool GUID_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + GUID_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool GUID_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -575,35 +544,27 @@ namespace eprosima { const GUID_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_GUID_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -616,49 +577,42 @@ namespace eprosima { SequenceNumber_sPubSubType::SequenceNumber_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::SequenceNumber_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceNumber_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_SequenceNumber_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::SequenceNumber_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_SequenceNumber_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceNumber_sPubSubType::~SequenceNumber_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceNumber_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceNumber_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -673,16 +627,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceNumber_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -691,18 +641,14 @@ namespace eprosima { SequenceNumber_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -715,52 +661,62 @@ namespace eprosima { return true; } - std::function SequenceNumber_sPubSubType::getSerializedSizeProvider( + uint32_t SequenceNumber_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* SequenceNumber_sPubSubType::createData() + 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* SequenceNumber_sPubSubType::create_data() { return reinterpret_cast(new SequenceNumber_s()); } - void SequenceNumber_sPubSubType::deleteData( + void SequenceNumber_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool SequenceNumber_sPubSubType::getKey( + bool SequenceNumber_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + SequenceNumber_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool SequenceNumber_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -768,35 +724,27 @@ namespace eprosima { const SequenceNumber_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_SequenceNumber_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -809,49 +757,42 @@ namespace eprosima { SampleIdentity_sPubSubType::SampleIdentity_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::SampleIdentity_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(SampleIdentity_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_SampleIdentity_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::SampleIdentity_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_SampleIdentity_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SampleIdentity_sPubSubType::~SampleIdentity_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SampleIdentity_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SampleIdentity_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -866,16 +807,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SampleIdentity_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -884,18 +821,14 @@ namespace eprosima { SampleIdentity_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -908,52 +841,62 @@ namespace eprosima { return true; } - std::function SampleIdentity_sPubSubType::getSerializedSizeProvider( + uint32_t SampleIdentity_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* SampleIdentity_sPubSubType::createData() + 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* SampleIdentity_sPubSubType::create_data() { return reinterpret_cast(new SampleIdentity_s()); } - void SampleIdentity_sPubSubType::deleteData( + void SampleIdentity_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool SampleIdentity_sPubSubType::getKey( + bool SampleIdentity_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + SampleIdentity_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool SampleIdentity_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -961,35 +904,27 @@ namespace eprosima { const SampleIdentity_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_SampleIdentity_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1002,49 +937,42 @@ namespace eprosima { Locator_sPubSubType::Locator_sPubSubType() { - setName("eprosima::fastdds::statistics::detail::Locator_s"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Locator_s::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_detail_Locator_s_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::detail::Locator_s"); + uint32_t type_size = eprosima_fastdds_statistics_detail_Locator_s_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Locator_sPubSubType::~Locator_sPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Locator_sPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Locator_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1059,16 +987,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Locator_sPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1077,18 +1001,14 @@ namespace eprosima { Locator_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1101,52 +1021,62 @@ namespace eprosima { return true; } - std::function Locator_sPubSubType::getSerializedSizeProvider( + uint32_t Locator_sPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Locator_sPubSubType::createData() + 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* Locator_sPubSubType::create_data() { return reinterpret_cast(new Locator_s()); } - void Locator_sPubSubType::deleteData( + void Locator_sPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Locator_sPubSubType::getKey( + bool Locator_sPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Locator_s data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Locator_sPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1154,35 +1084,27 @@ namespace eprosima { const Locator_s* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_detail_Locator_s_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1197,49 +1119,42 @@ namespace eprosima { DiscoveryTimePubSubType::DiscoveryTimePubSubType() { - setName("eprosima::fastdds::statistics::DiscoveryTime"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(DiscoveryTime::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_DiscoveryTime_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::DiscoveryTime"); + uint32_t type_size = eprosima_fastdds_statistics_DiscoveryTime_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DiscoveryTimePubSubType::~DiscoveryTimePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DiscoveryTimePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const DiscoveryTime* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1254,16 +1169,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DiscoveryTimePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1272,18 +1183,14 @@ namespace eprosima { DiscoveryTime* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1296,52 +1203,62 @@ namespace eprosima { return true; } - std::function DiscoveryTimePubSubType::getSerializedSizeProvider( + uint32_t DiscoveryTimePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* DiscoveryTimePubSubType::createData() + 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* DiscoveryTimePubSubType::create_data() { return reinterpret_cast(new DiscoveryTime()); } - void DiscoveryTimePubSubType::deleteData( + void DiscoveryTimePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool DiscoveryTimePubSubType::getKey( + bool DiscoveryTimePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + DiscoveryTime data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool DiscoveryTimePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1349,35 +1266,27 @@ namespace eprosima { const DiscoveryTime* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_DiscoveryTime_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1390,49 +1299,42 @@ namespace eprosima { EntityCountPubSubType::EntityCountPubSubType() { - setName("eprosima::fastdds::statistics::EntityCount"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(EntityCount::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_EntityCount_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::EntityCount"); + uint32_t type_size = eprosima_fastdds_statistics_EntityCount_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EntityCountPubSubType::~EntityCountPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EntityCountPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EntityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1447,16 +1349,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EntityCountPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1465,18 +1363,14 @@ namespace eprosima { EntityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1489,52 +1383,62 @@ namespace eprosima { return true; } - std::function EntityCountPubSubType::getSerializedSizeProvider( + uint32_t EntityCountPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* EntityCountPubSubType::createData() + 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* EntityCountPubSubType::create_data() { return reinterpret_cast(new EntityCount()); } - void EntityCountPubSubType::deleteData( + void EntityCountPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool EntityCountPubSubType::getKey( + bool EntityCountPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + EntityCount data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool EntityCountPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1542,35 +1446,27 @@ namespace eprosima { const EntityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_EntityCount_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1583,49 +1479,42 @@ namespace eprosima { SampleIdentityCountPubSubType::SampleIdentityCountPubSubType() { - setName("eprosima::fastdds::statistics::SampleIdentityCount"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(SampleIdentityCount::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_SampleIdentityCount_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::SampleIdentityCount"); + uint32_t type_size = eprosima_fastdds_statistics_SampleIdentityCount_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SampleIdentityCountPubSubType::~SampleIdentityCountPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SampleIdentityCountPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SampleIdentityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1640,16 +1529,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SampleIdentityCountPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1658,18 +1543,14 @@ namespace eprosima { SampleIdentityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1682,52 +1563,62 @@ namespace eprosima { return true; } - std::function SampleIdentityCountPubSubType::getSerializedSizeProvider( + uint32_t SampleIdentityCountPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* SampleIdentityCountPubSubType::createData() + 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* SampleIdentityCountPubSubType::create_data() { return reinterpret_cast(new SampleIdentityCount()); } - void SampleIdentityCountPubSubType::deleteData( + void SampleIdentityCountPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool SampleIdentityCountPubSubType::getKey( + bool SampleIdentityCountPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + SampleIdentityCount data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool SampleIdentityCountPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1735,35 +1626,27 @@ namespace eprosima { const SampleIdentityCount* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_SampleIdentityCount_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1776,49 +1659,42 @@ namespace eprosima { Entity2LocatorTrafficPubSubType::Entity2LocatorTrafficPubSubType() { - setName("eprosima::fastdds::statistics::Entity2LocatorTraffic"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Entity2LocatorTraffic::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_Entity2LocatorTraffic_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::Entity2LocatorTraffic"); + uint32_t type_size = eprosima_fastdds_statistics_Entity2LocatorTraffic_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Entity2LocatorTrafficPubSubType::~Entity2LocatorTrafficPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Entity2LocatorTrafficPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Entity2LocatorTraffic* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1833,16 +1709,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Entity2LocatorTrafficPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1851,18 +1723,14 @@ namespace eprosima { Entity2LocatorTraffic* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1875,52 +1743,62 @@ namespace eprosima { return true; } - std::function Entity2LocatorTrafficPubSubType::getSerializedSizeProvider( + uint32_t Entity2LocatorTrafficPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Entity2LocatorTrafficPubSubType::createData() + 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* Entity2LocatorTrafficPubSubType::create_data() { return reinterpret_cast(new Entity2LocatorTraffic()); } - void Entity2LocatorTrafficPubSubType::deleteData( + void Entity2LocatorTrafficPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Entity2LocatorTrafficPubSubType::getKey( + bool Entity2LocatorTrafficPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Entity2LocatorTraffic data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Entity2LocatorTrafficPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1928,35 +1806,27 @@ namespace eprosima { const Entity2LocatorTraffic* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_Entity2LocatorTraffic_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1969,49 +1839,42 @@ namespace eprosima { WriterReaderDataPubSubType::WriterReaderDataPubSubType() { - setName("eprosima::fastdds::statistics::WriterReaderData"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(WriterReaderData::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_WriterReaderData_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::WriterReaderData"); + uint32_t type_size = eprosima_fastdds_statistics_WriterReaderData_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } WriterReaderDataPubSubType::~WriterReaderDataPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool WriterReaderDataPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const WriterReaderData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2026,16 +1889,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool WriterReaderDataPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2044,18 +1903,14 @@ namespace eprosima { WriterReaderData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2068,52 +1923,62 @@ namespace eprosima { return true; } - std::function WriterReaderDataPubSubType::getSerializedSizeProvider( + uint32_t WriterReaderDataPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* WriterReaderDataPubSubType::createData() + 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* WriterReaderDataPubSubType::create_data() { return reinterpret_cast(new WriterReaderData()); } - void WriterReaderDataPubSubType::deleteData( + void WriterReaderDataPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool WriterReaderDataPubSubType::getKey( + bool WriterReaderDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + WriterReaderData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool WriterReaderDataPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2121,35 +1986,27 @@ namespace eprosima { const WriterReaderData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_WriterReaderData_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2162,49 +2019,42 @@ namespace eprosima { Locator2LocatorDataPubSubType::Locator2LocatorDataPubSubType() { - setName("eprosima::fastdds::statistics::Locator2LocatorData"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Locator2LocatorData::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_Locator2LocatorData_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::Locator2LocatorData"); + uint32_t type_size = eprosima_fastdds_statistics_Locator2LocatorData_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Locator2LocatorDataPubSubType::~Locator2LocatorDataPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Locator2LocatorDataPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Locator2LocatorData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2219,16 +2069,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Locator2LocatorDataPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2237,18 +2083,14 @@ namespace eprosima { Locator2LocatorData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2261,52 +2103,62 @@ namespace eprosima { return true; } - std::function Locator2LocatorDataPubSubType::getSerializedSizeProvider( + uint32_t Locator2LocatorDataPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Locator2LocatorDataPubSubType::createData() + 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* Locator2LocatorDataPubSubType::create_data() { return reinterpret_cast(new Locator2LocatorData()); } - void Locator2LocatorDataPubSubType::deleteData( + void Locator2LocatorDataPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Locator2LocatorDataPubSubType::getKey( + bool Locator2LocatorDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Locator2LocatorData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Locator2LocatorDataPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2314,35 +2166,27 @@ namespace eprosima { const Locator2LocatorData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_Locator2LocatorData_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2355,49 +2199,42 @@ namespace eprosima { EntityDataPubSubType::EntityDataPubSubType() { - setName("eprosima::fastdds::statistics::EntityData"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(EntityData::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_EntityData_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::EntityData"); + uint32_t type_size = eprosima_fastdds_statistics_EntityData_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EntityDataPubSubType::~EntityDataPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EntityDataPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EntityData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2412,16 +2249,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EntityDataPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2430,18 +2263,14 @@ namespace eprosima { EntityData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2454,52 +2283,62 @@ namespace eprosima { return true; } - std::function EntityDataPubSubType::getSerializedSizeProvider( + uint32_t EntityDataPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* EntityDataPubSubType::createData() + 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* EntityDataPubSubType::create_data() { return reinterpret_cast(new EntityData()); } - void EntityDataPubSubType::deleteData( + void EntityDataPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool EntityDataPubSubType::getKey( + bool EntityDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + EntityData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool EntityDataPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2507,35 +2346,27 @@ namespace eprosima { const EntityData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_EntityData_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2548,49 +2379,42 @@ namespace eprosima { PhysicalDataPubSubType::PhysicalDataPubSubType() { - setName("eprosima::fastdds::statistics::PhysicalData"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(PhysicalData::getMaxCdrSerializedSize()); - #else - eprosima_fastdds_statistics_PhysicalData_max_cdr_typesize; - #endif + set_name("eprosima::fastdds::statistics::PhysicalData"); + uint32_t type_size = eprosima_fastdds_statistics_PhysicalData_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize > 16 ? eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PhysicalDataPubSubType::~PhysicalDataPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PhysicalDataPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PhysicalData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2605,16 +2429,12 @@ namespace eprosima { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PhysicalDataPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2623,18 +2443,14 @@ namespace eprosima { PhysicalData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2647,52 +2463,62 @@ namespace eprosima { return true; } - std::function PhysicalDataPubSubType::getSerializedSizeProvider( + uint32_t PhysicalDataPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* PhysicalDataPubSubType::createData() + 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* PhysicalDataPubSubType::create_data() { return reinterpret_cast(new PhysicalData()); } - void PhysicalDataPubSubType::deleteData( + void PhysicalDataPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool PhysicalDataPubSubType::getKey( + bool PhysicalDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + PhysicalData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool PhysicalDataPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2700,35 +2526,27 @@ namespace eprosima { const PhysicalData* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_fastdds_statistics_PhysicalData_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/blackbox/types/statistics/typesPubSubTypes.hpp b/test/blackbox/types/statistics/typesPubSubTypes.hpp index fb99b8c567d..3a7c7aa0ad6 100644 --- a/test/blackbox/types/statistics/typesPubSubTypes.hpp +++ b/test/blackbox/types/statistics/typesPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "types.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated types is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER namespace eprosima { @@ -62,38 +62,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -108,10 +100,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -132,8 +120,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -153,38 +143,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -199,10 +181,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -223,8 +201,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -244,38 +224,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -290,10 +262,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -314,8 +282,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -335,38 +305,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -381,10 +343,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -405,8 +363,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -426,38 +386,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -472,10 +424,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -496,8 +444,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -517,38 +467,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -563,10 +505,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -587,8 +525,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace detail @@ -609,38 +549,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -655,10 +587,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -679,8 +607,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -700,38 +630,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -746,10 +668,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -770,8 +688,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -791,38 +711,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -837,10 +749,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -861,8 +769,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -882,38 +792,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -928,10 +830,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -952,8 +850,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -973,38 +873,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1019,10 +911,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1043,8 +931,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1064,38 +954,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1110,10 +992,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1134,8 +1012,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1155,38 +1035,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1201,10 +1073,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1225,8 +1093,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1246,38 +1116,30 @@ namespace eprosima eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1292,10 +1154,6 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1316,8 +1174,10 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; namespace EventKind diff --git a/test/dds-types-test/aliasesPubSubTypes.cxx b/test/dds-types-test/aliasesPubSubTypes.cxx index 763cadc162e..997c799cc90 100644 --- a/test/dds-types-test/aliasesPubSubTypes.cxx +++ b/test/dds-types-test/aliasesPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; AliasInt16PubSubType::AliasInt16PubSubType() { - setName("AliasInt16"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasInt16::getMaxCdrSerializedSize()); -#else - AliasInt16_max_cdr_typesize; -#endif + set_name("AliasInt16"); + uint32_t type_size = AliasInt16_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasInt16_max_key_cdr_typesize > 16 ? AliasInt16_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasInt16_max_key_cdr_typesize > 16 ? AliasInt16_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasInt16PubSubType::~AliasInt16PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasInt16PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasInt16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool AliasInt16PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasInt16PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool AliasInt16PubSubType::deserialize( AliasInt16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool AliasInt16PubSubType::deserialize( return true; } -std::function AliasInt16PubSubType::getSerializedSizeProvider( +uint32_t AliasInt16PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasInt16PubSubType::createData() + 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* AliasInt16PubSubType::create_data() { return reinterpret_cast(new AliasInt16()); } -void AliasInt16PubSubType::deleteData( +void AliasInt16PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasInt16PubSubType::getKey( +bool AliasInt16PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasInt16 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasInt16PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool AliasInt16PubSubType::getKey( const AliasInt16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasInt16_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasInt16_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void AliasInt16PubSubType::register_type_object_representation() AliasUint16PubSubType::AliasUint16PubSubType() { - setName("AliasUint16"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasUint16::getMaxCdrSerializedSize()); -#else - AliasUint16_max_cdr_typesize; -#endif + set_name("AliasUint16"); + uint32_t type_size = AliasUint16_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasUint16_max_key_cdr_typesize > 16 ? AliasUint16_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasUint16_max_key_cdr_typesize > 16 ? AliasUint16_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasUint16PubSubType::~AliasUint16PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasUint16PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasUint16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool AliasUint16PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasUint16PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool AliasUint16PubSubType::deserialize( AliasUint16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool AliasUint16PubSubType::deserialize( return true; } -std::function AliasUint16PubSubType::getSerializedSizeProvider( +uint32_t AliasUint16PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasUint16PubSubType::createData() + 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* AliasUint16PubSubType::create_data() { return reinterpret_cast(new AliasUint16()); } -void AliasUint16PubSubType::deleteData( +void AliasUint16PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasUint16PubSubType::getKey( +bool AliasUint16PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasUint16 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasUint16PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool AliasUint16PubSubType::getKey( const AliasUint16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasUint16_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasUint16_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void AliasUint16PubSubType::register_type_object_representation() AliasInt32PubSubType::AliasInt32PubSubType() { - setName("AliasInt32"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasInt32::getMaxCdrSerializedSize()); -#else - AliasInt32_max_cdr_typesize; -#endif + set_name("AliasInt32"); + uint32_t type_size = AliasInt32_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasInt32_max_key_cdr_typesize > 16 ? AliasInt32_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasInt32_max_key_cdr_typesize > 16 ? AliasInt32_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasInt32PubSubType::~AliasInt32PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasInt32PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasInt32* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool AliasInt32PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasInt32PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool AliasInt32PubSubType::deserialize( AliasInt32* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool AliasInt32PubSubType::deserialize( return true; } -std::function AliasInt32PubSubType::getSerializedSizeProvider( +uint32_t AliasInt32PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasInt32PubSubType::createData() + 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* AliasInt32PubSubType::create_data() { return reinterpret_cast(new AliasInt32()); } -void AliasInt32PubSubType::deleteData( +void AliasInt32PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasInt32PubSubType::getKey( +bool AliasInt32PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasInt32 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasInt32PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool AliasInt32PubSubType::getKey( const AliasInt32* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasInt32_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasInt32_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void AliasInt32PubSubType::register_type_object_representation() AliasUInt32PubSubType::AliasUInt32PubSubType() { - setName("AliasUInt32"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasUInt32::getMaxCdrSerializedSize()); -#else - AliasUInt32_max_cdr_typesize; -#endif + set_name("AliasUInt32"); + uint32_t type_size = AliasUInt32_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasUInt32_max_key_cdr_typesize > 16 ? AliasUInt32_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasUInt32_max_key_cdr_typesize > 16 ? AliasUInt32_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasUInt32PubSubType::~AliasUInt32PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasUInt32PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasUInt32* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool AliasUInt32PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasUInt32PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool AliasUInt32PubSubType::deserialize( AliasUInt32* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool AliasUInt32PubSubType::deserialize( return true; } -std::function AliasUInt32PubSubType::getSerializedSizeProvider( +uint32_t AliasUInt32PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasUInt32PubSubType::createData() + 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* AliasUInt32PubSubType::create_data() { return reinterpret_cast(new AliasUInt32()); } -void AliasUInt32PubSubType::deleteData( +void AliasUInt32PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasUInt32PubSubType::getKey( +bool AliasUInt32PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasUInt32 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasUInt32PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool AliasUInt32PubSubType::getKey( const AliasUInt32* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasUInt32_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasUInt32_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void AliasUInt32PubSubType::register_type_object_representation() AliasInt64PubSubType::AliasInt64PubSubType() { - setName("AliasInt64"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasInt64::getMaxCdrSerializedSize()); -#else - AliasInt64_max_cdr_typesize; -#endif + set_name("AliasInt64"); + uint32_t type_size = AliasInt64_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasInt64_max_key_cdr_typesize > 16 ? AliasInt64_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasInt64_max_key_cdr_typesize > 16 ? AliasInt64_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasInt64PubSubType::~AliasInt64PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasInt64PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasInt64* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool AliasInt64PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasInt64PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool AliasInt64PubSubType::deserialize( AliasInt64* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool AliasInt64PubSubType::deserialize( return true; } -std::function AliasInt64PubSubType::getSerializedSizeProvider( +uint32_t AliasInt64PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasInt64PubSubType::createData() + 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* AliasInt64PubSubType::create_data() { return reinterpret_cast(new AliasInt64()); } -void AliasInt64PubSubType::deleteData( +void AliasInt64PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasInt64PubSubType::getKey( +bool AliasInt64PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasInt64 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasInt64PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool AliasInt64PubSubType::getKey( const AliasInt64* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasInt64_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasInt64_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void AliasInt64PubSubType::register_type_object_representation() AliasUInt64PubSubType::AliasUInt64PubSubType() { - setName("AliasUInt64"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasUInt64::getMaxCdrSerializedSize()); -#else - AliasUInt64_max_cdr_typesize; -#endif + set_name("AliasUInt64"); + uint32_t type_size = AliasUInt64_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasUInt64_max_key_cdr_typesize > 16 ? AliasUInt64_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasUInt64_max_key_cdr_typesize > 16 ? AliasUInt64_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasUInt64PubSubType::~AliasUInt64PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasUInt64PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasUInt64* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool AliasUInt64PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasUInt64PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool AliasUInt64PubSubType::deserialize( AliasUInt64* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool AliasUInt64PubSubType::deserialize( return true; } -std::function AliasUInt64PubSubType::getSerializedSizeProvider( +uint32_t AliasUInt64PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasUInt64PubSubType::createData() + 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* AliasUInt64PubSubType::create_data() { return reinterpret_cast(new AliasUInt64()); } -void AliasUInt64PubSubType::deleteData( +void AliasUInt64PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasUInt64PubSubType::getKey( +bool AliasUInt64PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasUInt64 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasUInt64PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool AliasUInt64PubSubType::getKey( const AliasUInt64* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasUInt64_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasUInt64_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void AliasUInt64PubSubType::register_type_object_representation() AliasFloat32PubSubType::AliasFloat32PubSubType() { - setName("AliasFloat32"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasFloat32::getMaxCdrSerializedSize()); -#else - AliasFloat32_max_cdr_typesize; -#endif + set_name("AliasFloat32"); + uint32_t type_size = AliasFloat32_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasFloat32_max_key_cdr_typesize > 16 ? AliasFloat32_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasFloat32_max_key_cdr_typesize > 16 ? AliasFloat32_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasFloat32PubSubType::~AliasFloat32PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasFloat32PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasFloat32* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool AliasFloat32PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasFloat32PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool AliasFloat32PubSubType::deserialize( AliasFloat32* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool AliasFloat32PubSubType::deserialize( return true; } -std::function AliasFloat32PubSubType::getSerializedSizeProvider( +uint32_t AliasFloat32PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasFloat32PubSubType::createData() + 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* AliasFloat32PubSubType::create_data() { return reinterpret_cast(new AliasFloat32()); } -void AliasFloat32PubSubType::deleteData( +void AliasFloat32PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasFloat32PubSubType::getKey( +bool AliasFloat32PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasFloat32 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasFloat32PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool AliasFloat32PubSubType::getKey( const AliasFloat32* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasFloat32_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasFloat32_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void AliasFloat32PubSubType::register_type_object_representation() AliasFloat64PubSubType::AliasFloat64PubSubType() { - setName("AliasFloat64"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasFloat64::getMaxCdrSerializedSize()); -#else - AliasFloat64_max_cdr_typesize; -#endif + set_name("AliasFloat64"); + uint32_t type_size = AliasFloat64_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasFloat64_max_key_cdr_typesize > 16 ? AliasFloat64_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasFloat64_max_key_cdr_typesize > 16 ? AliasFloat64_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasFloat64PubSubType::~AliasFloat64PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasFloat64PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasFloat64* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool AliasFloat64PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasFloat64PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool AliasFloat64PubSubType::deserialize( AliasFloat64* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool AliasFloat64PubSubType::deserialize( return true; } -std::function AliasFloat64PubSubType::getSerializedSizeProvider( +uint32_t AliasFloat64PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasFloat64PubSubType::createData() + 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* AliasFloat64PubSubType::create_data() { return reinterpret_cast(new AliasFloat64()); } -void AliasFloat64PubSubType::deleteData( +void AliasFloat64PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasFloat64PubSubType::getKey( +bool AliasFloat64PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasFloat64 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasFloat64PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool AliasFloat64PubSubType::getKey( const AliasFloat64* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasFloat64_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasFloat64_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void AliasFloat64PubSubType::register_type_object_representation() AliasFloat128PubSubType::AliasFloat128PubSubType() { - setName("AliasFloat128"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasFloat128::getMaxCdrSerializedSize()); -#else - AliasFloat128_max_cdr_typesize; -#endif + set_name("AliasFloat128"); + uint32_t type_size = AliasFloat128_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasFloat128_max_key_cdr_typesize > 16 ? AliasFloat128_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasFloat128_max_key_cdr_typesize > 16 ? AliasFloat128_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasFloat128PubSubType::~AliasFloat128PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasFloat128PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasFloat128* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool AliasFloat128PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasFloat128PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool AliasFloat128PubSubType::deserialize( AliasFloat128* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool AliasFloat128PubSubType::deserialize( return true; } -std::function AliasFloat128PubSubType::getSerializedSizeProvider( +uint32_t AliasFloat128PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasFloat128PubSubType::createData() + 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* AliasFloat128PubSubType::create_data() { return reinterpret_cast(new AliasFloat128()); } -void AliasFloat128PubSubType::deleteData( +void AliasFloat128PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasFloat128PubSubType::getKey( +bool AliasFloat128PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasFloat128 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasFloat128PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool AliasFloat128PubSubType::getKey( const AliasFloat128* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasFloat128_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasFloat128_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void AliasFloat128PubSubType::register_type_object_representation() AliasBoolPubSubType::AliasBoolPubSubType() { - setName("AliasBool"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasBool::getMaxCdrSerializedSize()); -#else - AliasBool_max_cdr_typesize; -#endif + set_name("AliasBool"); + uint32_t type_size = AliasBool_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasBool_max_key_cdr_typesize > 16 ? AliasBool_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasBool_max_key_cdr_typesize > 16 ? AliasBool_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasBoolPubSubType::~AliasBoolPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasBoolPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasBool* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool AliasBoolPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasBoolPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool AliasBoolPubSubType::deserialize( AliasBool* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool AliasBoolPubSubType::deserialize( return true; } -std::function AliasBoolPubSubType::getSerializedSizeProvider( +uint32_t AliasBoolPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasBoolPubSubType::createData() + 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* AliasBoolPubSubType::create_data() { return reinterpret_cast(new AliasBool()); } -void AliasBoolPubSubType::deleteData( +void AliasBoolPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasBoolPubSubType::getKey( +bool AliasBoolPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasBool data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasBoolPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool AliasBoolPubSubType::getKey( const AliasBool* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasBool_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasBool_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void AliasBoolPubSubType::register_type_object_representation() AliasOctetPubSubType::AliasOctetPubSubType() { - setName("AliasOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasOctet::getMaxCdrSerializedSize()); -#else - AliasOctet_max_cdr_typesize; -#endif + set_name("AliasOctet"); + uint32_t type_size = AliasOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasOctet_max_key_cdr_typesize > 16 ? AliasOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasOctet_max_key_cdr_typesize > 16 ? AliasOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasOctetPubSubType::~AliasOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool AliasOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool AliasOctetPubSubType::deserialize( AliasOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool AliasOctetPubSubType::deserialize( return true; } -std::function AliasOctetPubSubType::getSerializedSizeProvider( +uint32_t AliasOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasOctetPubSubType::createData() + 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* AliasOctetPubSubType::create_data() { return reinterpret_cast(new AliasOctet()); } -void AliasOctetPubSubType::deleteData( +void AliasOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasOctetPubSubType::getKey( +bool AliasOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool AliasOctetPubSubType::getKey( const AliasOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void AliasOctetPubSubType::register_type_object_representation() AliasChar8PubSubType::AliasChar8PubSubType() { - setName("AliasChar8"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasChar8::getMaxCdrSerializedSize()); -#else - AliasChar8_max_cdr_typesize; -#endif + set_name("AliasChar8"); + uint32_t type_size = AliasChar8_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasChar8_max_key_cdr_typesize > 16 ? AliasChar8_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasChar8_max_key_cdr_typesize > 16 ? AliasChar8_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasChar8PubSubType::~AliasChar8PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasChar8PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasChar8* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool AliasChar8PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasChar8PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool AliasChar8PubSubType::deserialize( AliasChar8* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool AliasChar8PubSubType::deserialize( return true; } -std::function AliasChar8PubSubType::getSerializedSizeProvider( +uint32_t AliasChar8PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasChar8PubSubType::createData() + 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* AliasChar8PubSubType::create_data() { return reinterpret_cast(new AliasChar8()); } -void AliasChar8PubSubType::deleteData( +void AliasChar8PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasChar8PubSubType::getKey( +bool AliasChar8PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasChar8 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasChar8PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool AliasChar8PubSubType::getKey( const AliasChar8* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasChar8_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasChar8_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void AliasChar8PubSubType::register_type_object_representation() AliasChar16PubSubType::AliasChar16PubSubType() { - setName("AliasChar16"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasChar16::getMaxCdrSerializedSize()); -#else - AliasChar16_max_cdr_typesize; -#endif + set_name("AliasChar16"); + uint32_t type_size = AliasChar16_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasChar16_max_key_cdr_typesize > 16 ? AliasChar16_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasChar16_max_key_cdr_typesize > 16 ? AliasChar16_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasChar16PubSubType::~AliasChar16PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasChar16PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasChar16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool AliasChar16PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasChar16PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool AliasChar16PubSubType::deserialize( AliasChar16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,52 +2277,62 @@ bool AliasChar16PubSubType::deserialize( return true; } -std::function AliasChar16PubSubType::getSerializedSizeProvider( +uint32_t AliasChar16PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasChar16PubSubType::createData() + 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* AliasChar16PubSubType::create_data() { return reinterpret_cast(new AliasChar16()); } -void AliasChar16PubSubType::deleteData( +void AliasChar16PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasChar16PubSubType::getKey( +bool AliasChar16PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasChar16 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasChar16PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2501,35 +2340,27 @@ bool AliasChar16PubSubType::getKey( const AliasChar16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasChar16_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasChar16_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void AliasChar16PubSubType::register_type_object_representation() AliasString8PubSubType::AliasString8PubSubType() { - setName("AliasString8"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasString8::getMaxCdrSerializedSize()); -#else - AliasString8_max_cdr_typesize; -#endif + set_name("AliasString8"); + uint32_t type_size = AliasString8_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasString8_max_key_cdr_typesize > 16 ? AliasString8_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasString8_max_key_cdr_typesize > 16 ? AliasString8_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasString8PubSubType::~AliasString8PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasString8PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasString8* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool AliasString8PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasString8PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool AliasString8PubSubType::deserialize( AliasString8* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool AliasString8PubSubType::deserialize( return true; } -std::function AliasString8PubSubType::getSerializedSizeProvider( +uint32_t AliasString8PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasString8PubSubType::createData() + 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* AliasString8PubSubType::create_data() { return reinterpret_cast(new AliasString8()); } -void AliasString8PubSubType::deleteData( +void AliasString8PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasString8PubSubType::getKey( +bool AliasString8PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasString8 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasString8PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool AliasString8PubSubType::getKey( const AliasString8* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasString8_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasString8_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void AliasString8PubSubType::register_type_object_representation() AliasString16PubSubType::AliasString16PubSubType() { - setName("AliasString16"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasString16::getMaxCdrSerializedSize()); -#else - AliasString16_max_cdr_typesize; -#endif + set_name("AliasString16"); + uint32_t type_size = AliasString16_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasString16_max_key_cdr_typesize > 16 ? AliasString16_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasString16_max_key_cdr_typesize > 16 ? AliasString16_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasString16PubSubType::~AliasString16PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasString16PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasString16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool AliasString16PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasString16PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool AliasString16PubSubType::deserialize( AliasString16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool AliasString16PubSubType::deserialize( return true; } -std::function AliasString16PubSubType::getSerializedSizeProvider( +uint32_t AliasString16PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasString16PubSubType::createData() + 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* AliasString16PubSubType::create_data() { return reinterpret_cast(new AliasString16()); } -void AliasString16PubSubType::deleteData( +void AliasString16PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasString16PubSubType::getKey( +bool AliasString16PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasString16 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasString16PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool AliasString16PubSubType::getKey( const AliasString16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasString16_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasString16_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void AliasString16PubSubType::register_type_object_representation() AliasEnumPubSubType::AliasEnumPubSubType() { - setName("AliasEnum"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasEnum::getMaxCdrSerializedSize()); -#else - AliasEnum_max_cdr_typesize; -#endif + set_name("AliasEnum"); + uint32_t type_size = AliasEnum_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasEnum_max_key_cdr_typesize > 16 ? AliasEnum_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasEnum_max_key_cdr_typesize > 16 ? AliasEnum_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasEnumPubSubType::~AliasEnumPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasEnumPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool AliasEnumPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasEnumPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool AliasEnumPubSubType::deserialize( AliasEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool AliasEnumPubSubType::deserialize( return true; } -std::function AliasEnumPubSubType::getSerializedSizeProvider( +uint32_t AliasEnumPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasEnumPubSubType::createData() + 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* AliasEnumPubSubType::create_data() { return reinterpret_cast(new AliasEnum()); } -void AliasEnumPubSubType::deleteData( +void AliasEnumPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasEnumPubSubType::getKey( +bool AliasEnumPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasEnum data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasEnumPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool AliasEnumPubSubType::getKey( const AliasEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasEnum_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasEnum_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void AliasEnumPubSubType::register_type_object_representation() AliasBitmaskPubSubType::AliasBitmaskPubSubType() { - setName("AliasBitmask"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasBitmask::getMaxCdrSerializedSize()); -#else - AliasBitmask_max_cdr_typesize; -#endif + set_name("AliasBitmask"); + uint32_t type_size = AliasBitmask_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasBitmask_max_key_cdr_typesize > 16 ? AliasBitmask_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasBitmask_max_key_cdr_typesize > 16 ? AliasBitmask_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasBitmaskPubSubType::~AliasBitmaskPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasBitmaskPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasBitmask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool AliasBitmaskPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasBitmaskPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool AliasBitmaskPubSubType::deserialize( AliasBitmask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool AliasBitmaskPubSubType::deserialize( return true; } -std::function AliasBitmaskPubSubType::getSerializedSizeProvider( +uint32_t AliasBitmaskPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasBitmaskPubSubType::createData() + 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* AliasBitmaskPubSubType::create_data() { return reinterpret_cast(new AliasBitmask()); } -void AliasBitmaskPubSubType::deleteData( +void AliasBitmaskPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasBitmaskPubSubType::getKey( +bool AliasBitmaskPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasBitmask data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasBitmaskPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool AliasBitmaskPubSubType::getKey( const AliasBitmask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasBitmask_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasBitmask_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void AliasBitmaskPubSubType::register_type_object_representation() AliasAliasPubSubType::AliasAliasPubSubType() { - setName("AliasAlias"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasAlias::getMaxCdrSerializedSize()); -#else - AliasAlias_max_cdr_typesize; -#endif + set_name("AliasAlias"); + uint32_t type_size = AliasAlias_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasAlias_max_key_cdr_typesize > 16 ? AliasAlias_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasAlias_max_key_cdr_typesize > 16 ? AliasAlias_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasAliasPubSubType::~AliasAliasPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasAliasPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool AliasAliasPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasAliasPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool AliasAliasPubSubType::deserialize( AliasAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool AliasAliasPubSubType::deserialize( return true; } -std::function AliasAliasPubSubType::getSerializedSizeProvider( +uint32_t AliasAliasPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasAliasPubSubType::createData() + 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* AliasAliasPubSubType::create_data() { return reinterpret_cast(new AliasAlias()); } -void AliasAliasPubSubType::deleteData( +void AliasAliasPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasAliasPubSubType::getKey( +bool AliasAliasPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasAlias data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasAliasPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool AliasAliasPubSubType::getKey( const AliasAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasAlias_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasAlias_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void AliasAliasPubSubType::register_type_object_representation() AliasArrayPubSubType::AliasArrayPubSubType() { - setName("AliasArray"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasArray::getMaxCdrSerializedSize()); -#else - AliasArray_max_cdr_typesize; -#endif + set_name("AliasArray"); + uint32_t type_size = AliasArray_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasArray_max_key_cdr_typesize > 16 ? AliasArray_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasArray_max_key_cdr_typesize > 16 ? AliasArray_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasArrayPubSubType::~AliasArrayPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasArrayPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool AliasArrayPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasArrayPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool AliasArrayPubSubType::deserialize( AliasArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool AliasArrayPubSubType::deserialize( return true; } -std::function AliasArrayPubSubType::getSerializedSizeProvider( +uint32_t AliasArrayPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasArrayPubSubType::createData() + 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* AliasArrayPubSubType::create_data() { return reinterpret_cast(new AliasArray()); } -void AliasArrayPubSubType::deleteData( +void AliasArrayPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasArrayPubSubType::getKey( +bool AliasArrayPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasArray data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasArrayPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool AliasArrayPubSubType::getKey( const AliasArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasArray_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasArray_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3700,49 +3453,42 @@ void AliasArrayPubSubType::register_type_object_representation() AliasMultiArrayPubSubType::AliasMultiArrayPubSubType() { - setName("AliasMultiArray"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasMultiArray::getMaxCdrSerializedSize()); -#else - AliasMultiArray_max_cdr_typesize; -#endif + set_name("AliasMultiArray"); + uint32_t type_size = AliasMultiArray_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasMultiArray_max_key_cdr_typesize > 16 ? AliasMultiArray_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasMultiArray_max_key_cdr_typesize > 16 ? AliasMultiArray_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasMultiArrayPubSubType::~AliasMultiArrayPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasMultiArrayPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasMultiArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3757,16 +3503,12 @@ bool AliasMultiArrayPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasMultiArrayPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3775,18 +3517,14 @@ bool AliasMultiArrayPubSubType::deserialize( AliasMultiArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3799,52 +3537,62 @@ bool AliasMultiArrayPubSubType::deserialize( return true; } -std::function AliasMultiArrayPubSubType::getSerializedSizeProvider( +uint32_t AliasMultiArrayPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasMultiArrayPubSubType::createData() + 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* AliasMultiArrayPubSubType::create_data() { return reinterpret_cast(new AliasMultiArray()); } -void AliasMultiArrayPubSubType::deleteData( +void AliasMultiArrayPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasMultiArrayPubSubType::getKey( +bool AliasMultiArrayPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasMultiArray data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasMultiArrayPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3852,35 +3600,27 @@ bool AliasMultiArrayPubSubType::getKey( const AliasMultiArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasMultiArray_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasMultiArray_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3893,49 +3633,42 @@ void AliasMultiArrayPubSubType::register_type_object_representation() AliasSequencePubSubType::AliasSequencePubSubType() { - setName("AliasSequence"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasSequence::getMaxCdrSerializedSize()); -#else - AliasSequence_max_cdr_typesize; -#endif + set_name("AliasSequence"); + uint32_t type_size = AliasSequence_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasSequence_max_key_cdr_typesize > 16 ? AliasSequence_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasSequence_max_key_cdr_typesize > 16 ? AliasSequence_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasSequencePubSubType::~AliasSequencePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasSequencePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3950,16 +3683,12 @@ bool AliasSequencePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasSequencePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3968,18 +3697,14 @@ bool AliasSequencePubSubType::deserialize( AliasSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3992,52 +3717,62 @@ bool AliasSequencePubSubType::deserialize( return true; } -std::function AliasSequencePubSubType::getSerializedSizeProvider( +uint32_t AliasSequencePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasSequencePubSubType::createData() + 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* AliasSequencePubSubType::create_data() { return reinterpret_cast(new AliasSequence()); } -void AliasSequencePubSubType::deleteData( +void AliasSequencePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasSequencePubSubType::getKey( +bool AliasSequencePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasSequence data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasSequencePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4045,35 +3780,27 @@ bool AliasSequencePubSubType::getKey( const AliasSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasSequence_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasSequence_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4086,49 +3813,42 @@ void AliasSequencePubSubType::register_type_object_representation() AliasMapPubSubType::AliasMapPubSubType() { - setName("AliasMap"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasMap::getMaxCdrSerializedSize()); -#else - AliasMap_max_cdr_typesize; -#endif + set_name("AliasMap"); + uint32_t type_size = AliasMap_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasMap_max_key_cdr_typesize > 16 ? AliasMap_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasMap_max_key_cdr_typesize > 16 ? AliasMap_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasMapPubSubType::~AliasMapPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasMapPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4143,16 +3863,12 @@ bool AliasMapPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasMapPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4161,18 +3877,14 @@ bool AliasMapPubSubType::deserialize( AliasMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4185,52 +3897,62 @@ bool AliasMapPubSubType::deserialize( return true; } -std::function AliasMapPubSubType::getSerializedSizeProvider( +uint32_t AliasMapPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasMapPubSubType::createData() + 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* AliasMapPubSubType::create_data() { return reinterpret_cast(new AliasMap()); } -void AliasMapPubSubType::deleteData( +void AliasMapPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasMapPubSubType::getKey( +bool AliasMapPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasMap data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasMapPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4238,35 +3960,27 @@ bool AliasMapPubSubType::getKey( const AliasMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasMap_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasMap_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4279,49 +3993,42 @@ void AliasMapPubSubType::register_type_object_representation() AliasUnionPubSubType::AliasUnionPubSubType() { - setName("AliasUnion"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasUnion::getMaxCdrSerializedSize()); -#else - AliasUnion_max_cdr_typesize; -#endif + set_name("AliasUnion"); + uint32_t type_size = AliasUnion_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasUnion_max_key_cdr_typesize > 16 ? AliasUnion_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasUnion_max_key_cdr_typesize > 16 ? AliasUnion_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasUnionPubSubType::~AliasUnionPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasUnionPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4336,16 +4043,12 @@ bool AliasUnionPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasUnionPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4354,18 +4057,14 @@ bool AliasUnionPubSubType::deserialize( AliasUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4378,52 +4077,62 @@ bool AliasUnionPubSubType::deserialize( return true; } -std::function AliasUnionPubSubType::getSerializedSizeProvider( +uint32_t AliasUnionPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasUnionPubSubType::createData() + 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* AliasUnionPubSubType::create_data() { return reinterpret_cast(new AliasUnion()); } -void AliasUnionPubSubType::deleteData( +void AliasUnionPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasUnionPubSubType::getKey( +bool AliasUnionPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasUnion data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasUnionPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4431,35 +4140,27 @@ bool AliasUnionPubSubType::getKey( const AliasUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasUnion_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasUnion_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4472,49 +4173,42 @@ void AliasUnionPubSubType::register_type_object_representation() AliasStructPubSubType::AliasStructPubSubType() { - setName("AliasStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasStruct::getMaxCdrSerializedSize()); -#else - AliasStruct_max_cdr_typesize; -#endif + set_name("AliasStruct"); + uint32_t type_size = AliasStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasStruct_max_key_cdr_typesize > 16 ? AliasStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasStruct_max_key_cdr_typesize > 16 ? AliasStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasStructPubSubType::~AliasStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4529,16 +4223,12 @@ bool AliasStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4547,18 +4237,14 @@ bool AliasStructPubSubType::deserialize( AliasStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4571,52 +4257,62 @@ bool AliasStructPubSubType::deserialize( return true; } -std::function AliasStructPubSubType::getSerializedSizeProvider( +uint32_t AliasStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasStructPubSubType::createData() + 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* AliasStructPubSubType::create_data() { return reinterpret_cast(new AliasStruct()); } -void AliasStructPubSubType::deleteData( +void AliasStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasStructPubSubType::getKey( +bool AliasStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4624,35 +4320,27 @@ bool AliasStructPubSubType::getKey( const AliasStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4665,49 +4353,42 @@ void AliasStructPubSubType::register_type_object_representation() AliasBitsetPubSubType::AliasBitsetPubSubType() { - setName("AliasBitset"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasBitset::getMaxCdrSerializedSize()); -#else - AliasBitset_max_cdr_typesize; -#endif + set_name("AliasBitset"); + uint32_t type_size = AliasBitset_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasBitset_max_key_cdr_typesize > 16 ? AliasBitset_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasBitset_max_key_cdr_typesize > 16 ? AliasBitset_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasBitsetPubSubType::~AliasBitsetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasBitsetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4722,16 +4403,12 @@ bool AliasBitsetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasBitsetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4740,18 +4417,14 @@ bool AliasBitsetPubSubType::deserialize( AliasBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4764,52 +4437,62 @@ bool AliasBitsetPubSubType::deserialize( return true; } -std::function AliasBitsetPubSubType::getSerializedSizeProvider( +uint32_t AliasBitsetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AliasBitsetPubSubType::createData() + 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* AliasBitsetPubSubType::create_data() { return reinterpret_cast(new AliasBitset()); } -void AliasBitsetPubSubType::deleteData( +void AliasBitsetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasBitsetPubSubType::getKey( +bool AliasBitsetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasBitset data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasBitsetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4817,35 +4500,27 @@ bool AliasBitsetPubSubType::getKey( const AliasBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasBitset_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasBitset_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/aliasesPubSubTypes.hpp b/test/dds-types-test/aliasesPubSubTypes.hpp index 6ac00ba62c3..dd213b28d4d 100644 --- a/test/dds-types-test/aliasesPubSubTypes.hpp +++ b/test/dds-types-test/aliasesPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated aliases is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER typedef int16_t alias_int16; typedef uint16_t alias_uint16; @@ -80,38 +80,30 @@ class AliasInt16PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -126,10 +118,6 @@ class AliasInt16PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -150,8 +138,10 @@ class AliasInt16PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -171,38 +161,30 @@ class AliasUint16PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -217,10 +199,6 @@ class AliasUint16PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -241,8 +219,10 @@ class AliasUint16PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -262,38 +242,30 @@ class AliasInt32PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -308,10 +280,6 @@ class AliasInt32PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -332,8 +300,10 @@ class AliasInt32PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -353,38 +323,30 @@ class AliasUInt32PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -399,10 +361,6 @@ class AliasUInt32PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -423,8 +381,10 @@ class AliasUInt32PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -444,38 +404,30 @@ class AliasInt64PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -490,10 +442,6 @@ class AliasInt64PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -514,8 +462,10 @@ class AliasInt64PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -535,38 +485,30 @@ class AliasUInt64PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -581,10 +523,6 @@ class AliasUInt64PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -605,8 +543,10 @@ class AliasUInt64PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -626,38 +566,30 @@ class AliasFloat32PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -672,10 +604,6 @@ class AliasFloat32PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -696,8 +624,10 @@ class AliasFloat32PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -717,38 +647,30 @@ class AliasFloat64PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -763,10 +685,6 @@ class AliasFloat64PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -787,8 +705,10 @@ class AliasFloat64PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -808,38 +728,30 @@ class AliasFloat128PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -854,10 +766,6 @@ class AliasFloat128PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -878,8 +786,10 @@ class AliasFloat128PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -899,38 +809,30 @@ class AliasBoolPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -945,10 +847,6 @@ class AliasBoolPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -969,8 +867,10 @@ class AliasBoolPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -990,38 +890,30 @@ class AliasOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1036,10 +928,6 @@ class AliasOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1060,8 +948,10 @@ class AliasOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1081,38 +971,30 @@ class AliasChar8PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1127,10 +1009,6 @@ class AliasChar8PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1151,8 +1029,10 @@ class AliasChar8PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1172,38 +1052,30 @@ class AliasChar16PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1218,10 +1090,6 @@ class AliasChar16PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1242,8 +1110,10 @@ class AliasChar16PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1263,38 +1133,30 @@ class AliasString8PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1309,10 +1171,6 @@ class AliasString8PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1333,8 +1191,10 @@ class AliasString8PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1354,38 +1214,30 @@ class AliasString16PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1400,10 +1252,6 @@ class AliasString16PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1424,8 +1272,10 @@ class AliasString16PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1445,38 +1295,30 @@ class AliasEnumPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1491,10 +1333,6 @@ class AliasEnumPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1515,8 +1353,10 @@ class AliasEnumPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1536,38 +1376,30 @@ class AliasBitmaskPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1582,10 +1414,6 @@ class AliasBitmaskPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1606,8 +1434,10 @@ class AliasBitmaskPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1627,38 +1457,30 @@ class AliasAliasPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1673,10 +1495,6 @@ class AliasAliasPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1697,8 +1515,10 @@ class AliasAliasPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1718,38 +1538,30 @@ class AliasArrayPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1764,10 +1576,6 @@ class AliasArrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1788,8 +1596,10 @@ class AliasArrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1809,38 +1619,30 @@ class AliasMultiArrayPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1855,10 +1657,6 @@ class AliasMultiArrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1879,8 +1677,10 @@ class AliasMultiArrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1900,38 +1700,30 @@ class AliasSequencePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1946,10 +1738,6 @@ class AliasSequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1970,8 +1758,10 @@ class AliasSequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1991,38 +1781,30 @@ class AliasMapPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2037,10 +1819,6 @@ class AliasMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2061,8 +1839,10 @@ class AliasMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2082,38 +1862,30 @@ class AliasUnionPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2128,10 +1900,6 @@ class AliasUnionPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2152,8 +1920,10 @@ class AliasUnionPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2173,38 +1943,30 @@ class AliasStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2219,10 +1981,6 @@ class AliasStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2243,8 +2001,10 @@ class AliasStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2264,38 +2024,30 @@ class AliasBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2310,10 +2062,6 @@ class AliasBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2334,8 +2082,10 @@ class AliasBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/annotationsPubSubTypes.cxx b/test/dds-types-test/annotationsPubSubTypes.cxx index eef736b5191..68b623e534c 100644 --- a/test/dds-types-test/annotationsPubSubTypes.cxx +++ b/test/dds-types-test/annotationsPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; AnnotatedStructPubSubType::AnnotatedStructPubSubType() { - setName("AnnotatedStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AnnotatedStruct::getMaxCdrSerializedSize()); -#else - AnnotatedStruct_max_cdr_typesize; -#endif + set_name("AnnotatedStruct"); + uint32_t type_size = AnnotatedStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AnnotatedStruct_max_key_cdr_typesize > 16 ? AnnotatedStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AnnotatedStruct_max_key_cdr_typesize > 16 ? AnnotatedStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AnnotatedStructPubSubType::~AnnotatedStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AnnotatedStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AnnotatedStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool AnnotatedStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AnnotatedStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool AnnotatedStructPubSubType::deserialize( AnnotatedStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool AnnotatedStructPubSubType::deserialize( return true; } -std::function AnnotatedStructPubSubType::getSerializedSizeProvider( +uint32_t AnnotatedStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* AnnotatedStructPubSubType::createData() +void* AnnotatedStructPubSubType::create_data() { return reinterpret_cast(new AnnotatedStruct()); } -void AnnotatedStructPubSubType::deleteData( +void AnnotatedStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AnnotatedStructPubSubType::getKey( +bool AnnotatedStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AnnotatedStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AnnotatedStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool AnnotatedStructPubSubType::getKey( const AnnotatedStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AnnotatedStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AnnotatedStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void AnnotatedStructPubSubType::register_type_object_representation() EmptyAnnotatedStructPubSubType::EmptyAnnotatedStructPubSubType() { - setName("EmptyAnnotatedStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(EmptyAnnotatedStruct::getMaxCdrSerializedSize()); -#else - EmptyAnnotatedStruct_max_cdr_typesize; -#endif + set_name("EmptyAnnotatedStruct"); + uint32_t type_size = EmptyAnnotatedStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = EmptyAnnotatedStruct_max_key_cdr_typesize > 16 ? EmptyAnnotatedStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = EmptyAnnotatedStruct_max_key_cdr_typesize > 16 ? EmptyAnnotatedStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EmptyAnnotatedStructPubSubType::~EmptyAnnotatedStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EmptyAnnotatedStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EmptyAnnotatedStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool EmptyAnnotatedStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EmptyAnnotatedStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool EmptyAnnotatedStructPubSubType::deserialize( EmptyAnnotatedStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool EmptyAnnotatedStructPubSubType::deserialize( return true; } -std::function EmptyAnnotatedStructPubSubType::getSerializedSizeProvider( +uint32_t EmptyAnnotatedStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* EmptyAnnotatedStructPubSubType::createData() +void* EmptyAnnotatedStructPubSubType::create_data() { return reinterpret_cast(new EmptyAnnotatedStruct()); } -void EmptyAnnotatedStructPubSubType::deleteData( +void EmptyAnnotatedStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool EmptyAnnotatedStructPubSubType::getKey( +bool EmptyAnnotatedStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + EmptyAnnotatedStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool EmptyAnnotatedStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool EmptyAnnotatedStructPubSubType::getKey( const EmptyAnnotatedStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), EmptyAnnotatedStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || EmptyAnnotatedStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -420,49 +394,42 @@ void EmptyAnnotatedStructPubSubType::register_type_object_representation() BasicAnnotationsStructPubSubType::BasicAnnotationsStructPubSubType() { - setName("BasicAnnotationsStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BasicAnnotationsStruct::getMaxCdrSerializedSize()); -#else - BasicAnnotationsStruct_max_cdr_typesize; -#endif + set_name("BasicAnnotationsStruct"); + uint32_t type_size = BasicAnnotationsStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BasicAnnotationsStruct_max_key_cdr_typesize > 16 ? BasicAnnotationsStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BasicAnnotationsStruct_max_key_cdr_typesize > 16 ? BasicAnnotationsStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BasicAnnotationsStructPubSubType::~BasicAnnotationsStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BasicAnnotationsStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BasicAnnotationsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -477,16 +444,12 @@ bool BasicAnnotationsStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BasicAnnotationsStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -495,18 +458,14 @@ bool BasicAnnotationsStructPubSubType::deserialize( BasicAnnotationsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -519,52 +478,62 @@ bool BasicAnnotationsStructPubSubType::deserialize( return true; } -std::function BasicAnnotationsStructPubSubType::getSerializedSizeProvider( +uint32_t BasicAnnotationsStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* BasicAnnotationsStructPubSubType::createData() +void* BasicAnnotationsStructPubSubType::create_data() { return reinterpret_cast(new BasicAnnotationsStruct()); } -void BasicAnnotationsStructPubSubType::deleteData( +void BasicAnnotationsStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BasicAnnotationsStructPubSubType::getKey( +bool BasicAnnotationsStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BasicAnnotationsStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BasicAnnotationsStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -572,35 +541,27 @@ bool BasicAnnotationsStructPubSubType::getKey( const BasicAnnotationsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BasicAnnotationsStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BasicAnnotationsStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/annotationsPubSubTypes.hpp b/test/dds-types-test/annotationsPubSubTypes.hpp index ad990d06a56..413d5a9a33c 100644 --- a/test/dds-types-test/annotationsPubSubTypes.hpp +++ b/test/dds-types-test/annotationsPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated annotations is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class AnnotatedStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class AnnotatedStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class AnnotatedStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class EmptyAnnotatedStructPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class EmptyAnnotatedStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class EmptyAnnotatedStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -238,38 +218,30 @@ class BasicAnnotationsStructPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -284,10 +256,6 @@ class BasicAnnotationsStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -308,8 +276,10 @@ class BasicAnnotationsStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/appendablePubSubTypes.cxx b/test/dds-types-test/appendablePubSubTypes.cxx index 756bd87c45e..6b8dbf94777 100644 --- a/test/dds-types-test/appendablePubSubTypes.cxx +++ b/test/dds-types-test/appendablePubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; AppendableShortStructPubSubType::AppendableShortStructPubSubType() { - setName("AppendableShortStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableShortStruct::getMaxCdrSerializedSize()); -#else - AppendableShortStruct_max_cdr_typesize; -#endif + set_name("AppendableShortStruct"); + uint32_t type_size = AppendableShortStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableShortStruct_max_key_cdr_typesize > 16 ? AppendableShortStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableShortStruct_max_key_cdr_typesize > 16 ? AppendableShortStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableShortStructPubSubType::~AppendableShortStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableShortStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool AppendableShortStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableShortStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool AppendableShortStructPubSubType::deserialize( AppendableShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool AppendableShortStructPubSubType::deserialize( return true; } -std::function AppendableShortStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableShortStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableShortStructPubSubType::createData() + 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* AppendableShortStructPubSubType::create_data() { return reinterpret_cast(new AppendableShortStruct()); } -void AppendableShortStructPubSubType::deleteData( +void AppendableShortStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableShortStructPubSubType::getKey( +bool AppendableShortStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableShortStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableShortStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool AppendableShortStructPubSubType::getKey( const AppendableShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableShortStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableShortStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void AppendableShortStructPubSubType::register_type_object_representation() AppendableUShortStructPubSubType::AppendableUShortStructPubSubType() { - setName("AppendableUShortStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableUShortStruct::getMaxCdrSerializedSize()); -#else - AppendableUShortStruct_max_cdr_typesize; -#endif + set_name("AppendableUShortStruct"); + uint32_t type_size = AppendableUShortStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableUShortStruct_max_key_cdr_typesize > 16 ? AppendableUShortStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableUShortStruct_max_key_cdr_typesize > 16 ? AppendableUShortStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableUShortStructPubSubType::~AppendableUShortStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableUShortStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool AppendableUShortStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableUShortStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool AppendableUShortStructPubSubType::deserialize( AppendableUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool AppendableUShortStructPubSubType::deserialize( return true; } -std::function AppendableUShortStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableUShortStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableUShortStructPubSubType::createData() + 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* AppendableUShortStructPubSubType::create_data() { return reinterpret_cast(new AppendableUShortStruct()); } -void AppendableUShortStructPubSubType::deleteData( +void AppendableUShortStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableUShortStructPubSubType::getKey( +bool AppendableUShortStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableUShortStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableUShortStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool AppendableUShortStructPubSubType::getKey( const AppendableUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableUShortStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableUShortStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void AppendableUShortStructPubSubType::register_type_object_representation() AppendableLongStructPubSubType::AppendableLongStructPubSubType() { - setName("AppendableLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableLongStruct::getMaxCdrSerializedSize()); -#else - AppendableLongStruct_max_cdr_typesize; -#endif + set_name("AppendableLongStruct"); + uint32_t type_size = AppendableLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableLongStruct_max_key_cdr_typesize > 16 ? AppendableLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableLongStruct_max_key_cdr_typesize > 16 ? AppendableLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableLongStructPubSubType::~AppendableLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool AppendableLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool AppendableLongStructPubSubType::deserialize( AppendableLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool AppendableLongStructPubSubType::deserialize( return true; } -std::function AppendableLongStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableLongStructPubSubType::createData() + 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* AppendableLongStructPubSubType::create_data() { return reinterpret_cast(new AppendableLongStruct()); } -void AppendableLongStructPubSubType::deleteData( +void AppendableLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableLongStructPubSubType::getKey( +bool AppendableLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool AppendableLongStructPubSubType::getKey( const AppendableLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void AppendableLongStructPubSubType::register_type_object_representation() AppendableULongStructPubSubType::AppendableULongStructPubSubType() { - setName("AppendableULongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableULongStruct::getMaxCdrSerializedSize()); -#else - AppendableULongStruct_max_cdr_typesize; -#endif + set_name("AppendableULongStruct"); + uint32_t type_size = AppendableULongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableULongStruct_max_key_cdr_typesize > 16 ? AppendableULongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableULongStruct_max_key_cdr_typesize > 16 ? AppendableULongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableULongStructPubSubType::~AppendableULongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableULongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool AppendableULongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableULongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool AppendableULongStructPubSubType::deserialize( AppendableULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool AppendableULongStructPubSubType::deserialize( return true; } -std::function AppendableULongStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableULongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableULongStructPubSubType::createData() + 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* AppendableULongStructPubSubType::create_data() { return reinterpret_cast(new AppendableULongStruct()); } -void AppendableULongStructPubSubType::deleteData( +void AppendableULongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableULongStructPubSubType::getKey( +bool AppendableULongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableULongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableULongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool AppendableULongStructPubSubType::getKey( const AppendableULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableULongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableULongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void AppendableULongStructPubSubType::register_type_object_representation() AppendableLongLongStructPubSubType::AppendableLongLongStructPubSubType() { - setName("AppendableLongLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableLongLongStruct::getMaxCdrSerializedSize()); -#else - AppendableLongLongStruct_max_cdr_typesize; -#endif + set_name("AppendableLongLongStruct"); + uint32_t type_size = AppendableLongLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableLongLongStruct_max_key_cdr_typesize > 16 ? AppendableLongLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableLongLongStruct_max_key_cdr_typesize > 16 ? AppendableLongLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableLongLongStructPubSubType::~AppendableLongLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableLongLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool AppendableLongLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableLongLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool AppendableLongLongStructPubSubType::deserialize( AppendableLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool AppendableLongLongStructPubSubType::deserialize( return true; } -std::function AppendableLongLongStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableLongLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableLongLongStructPubSubType::createData() + 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* AppendableLongLongStructPubSubType::create_data() { return reinterpret_cast(new AppendableLongLongStruct()); } -void AppendableLongLongStructPubSubType::deleteData( +void AppendableLongLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableLongLongStructPubSubType::getKey( +bool AppendableLongLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableLongLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableLongLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool AppendableLongLongStructPubSubType::getKey( const AppendableLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableLongLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableLongLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void AppendableLongLongStructPubSubType::register_type_object_representation() AppendableULongLongStructPubSubType::AppendableULongLongStructPubSubType() { - setName("AppendableULongLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableULongLongStruct::getMaxCdrSerializedSize()); -#else - AppendableULongLongStruct_max_cdr_typesize; -#endif + set_name("AppendableULongLongStruct"); + uint32_t type_size = AppendableULongLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableULongLongStruct_max_key_cdr_typesize > 16 ? AppendableULongLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableULongLongStruct_max_key_cdr_typesize > 16 ? AppendableULongLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableULongLongStructPubSubType::~AppendableULongLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableULongLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool AppendableULongLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableULongLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool AppendableULongLongStructPubSubType::deserialize( AppendableULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool AppendableULongLongStructPubSubType::deserialize( return true; } -std::function AppendableULongLongStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableULongLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableULongLongStructPubSubType::createData() + 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* AppendableULongLongStructPubSubType::create_data() { return reinterpret_cast(new AppendableULongLongStruct()); } -void AppendableULongLongStructPubSubType::deleteData( +void AppendableULongLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableULongLongStructPubSubType::getKey( +bool AppendableULongLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableULongLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableULongLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool AppendableULongLongStructPubSubType::getKey( const AppendableULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableULongLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableULongLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void AppendableULongLongStructPubSubType::register_type_object_representation() AppendableFloatStructPubSubType::AppendableFloatStructPubSubType() { - setName("AppendableFloatStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableFloatStruct::getMaxCdrSerializedSize()); -#else - AppendableFloatStruct_max_cdr_typesize; -#endif + set_name("AppendableFloatStruct"); + uint32_t type_size = AppendableFloatStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableFloatStruct_max_key_cdr_typesize > 16 ? AppendableFloatStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableFloatStruct_max_key_cdr_typesize > 16 ? AppendableFloatStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableFloatStructPubSubType::~AppendableFloatStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableFloatStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool AppendableFloatStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableFloatStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool AppendableFloatStructPubSubType::deserialize( AppendableFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool AppendableFloatStructPubSubType::deserialize( return true; } -std::function AppendableFloatStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableFloatStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableFloatStructPubSubType::createData() + 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* AppendableFloatStructPubSubType::create_data() { return reinterpret_cast(new AppendableFloatStruct()); } -void AppendableFloatStructPubSubType::deleteData( +void AppendableFloatStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableFloatStructPubSubType::getKey( +bool AppendableFloatStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableFloatStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableFloatStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool AppendableFloatStructPubSubType::getKey( const AppendableFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableFloatStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableFloatStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void AppendableFloatStructPubSubType::register_type_object_representation() AppendableDoubleStructPubSubType::AppendableDoubleStructPubSubType() { - setName("AppendableDoubleStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableDoubleStruct::getMaxCdrSerializedSize()); -#else - AppendableDoubleStruct_max_cdr_typesize; -#endif + set_name("AppendableDoubleStruct"); + uint32_t type_size = AppendableDoubleStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableDoubleStruct_max_key_cdr_typesize > 16 ? AppendableDoubleStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableDoubleStruct_max_key_cdr_typesize > 16 ? AppendableDoubleStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableDoubleStructPubSubType::~AppendableDoubleStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableDoubleStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool AppendableDoubleStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableDoubleStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool AppendableDoubleStructPubSubType::deserialize( AppendableDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool AppendableDoubleStructPubSubType::deserialize( return true; } -std::function AppendableDoubleStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableDoubleStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableDoubleStructPubSubType::createData() + 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* AppendableDoubleStructPubSubType::create_data() { return reinterpret_cast(new AppendableDoubleStruct()); } -void AppendableDoubleStructPubSubType::deleteData( +void AppendableDoubleStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableDoubleStructPubSubType::getKey( +bool AppendableDoubleStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableDoubleStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableDoubleStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool AppendableDoubleStructPubSubType::getKey( const AppendableDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableDoubleStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableDoubleStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void AppendableDoubleStructPubSubType::register_type_object_representation() AppendableLongDoubleStructPubSubType::AppendableLongDoubleStructPubSubType() { - setName("AppendableLongDoubleStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableLongDoubleStruct::getMaxCdrSerializedSize()); -#else - AppendableLongDoubleStruct_max_cdr_typesize; -#endif + set_name("AppendableLongDoubleStruct"); + uint32_t type_size = AppendableLongDoubleStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableLongDoubleStruct_max_key_cdr_typesize > 16 ? AppendableLongDoubleStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableLongDoubleStruct_max_key_cdr_typesize > 16 ? AppendableLongDoubleStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableLongDoubleStructPubSubType::~AppendableLongDoubleStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableLongDoubleStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool AppendableLongDoubleStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableLongDoubleStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool AppendableLongDoubleStructPubSubType::deserialize( AppendableLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool AppendableLongDoubleStructPubSubType::deserialize( return true; } -std::function AppendableLongDoubleStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableLongDoubleStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableLongDoubleStructPubSubType::createData() + 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* AppendableLongDoubleStructPubSubType::create_data() { return reinterpret_cast(new AppendableLongDoubleStruct()); } -void AppendableLongDoubleStructPubSubType::deleteData( +void AppendableLongDoubleStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableLongDoubleStructPubSubType::getKey( +bool AppendableLongDoubleStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableLongDoubleStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableLongDoubleStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool AppendableLongDoubleStructPubSubType::getKey( const AppendableLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableLongDoubleStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableLongDoubleStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void AppendableLongDoubleStructPubSubType::register_type_object_representation() AppendableBooleanStructPubSubType::AppendableBooleanStructPubSubType() { - setName("AppendableBooleanStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableBooleanStruct::getMaxCdrSerializedSize()); -#else - AppendableBooleanStruct_max_cdr_typesize; -#endif + set_name("AppendableBooleanStruct"); + uint32_t type_size = AppendableBooleanStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableBooleanStruct_max_key_cdr_typesize > 16 ? AppendableBooleanStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableBooleanStruct_max_key_cdr_typesize > 16 ? AppendableBooleanStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableBooleanStructPubSubType::~AppendableBooleanStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableBooleanStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool AppendableBooleanStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableBooleanStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool AppendableBooleanStructPubSubType::deserialize( AppendableBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool AppendableBooleanStructPubSubType::deserialize( return true; } -std::function AppendableBooleanStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableBooleanStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableBooleanStructPubSubType::createData() + 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* AppendableBooleanStructPubSubType::create_data() { return reinterpret_cast(new AppendableBooleanStruct()); } -void AppendableBooleanStructPubSubType::deleteData( +void AppendableBooleanStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableBooleanStructPubSubType::getKey( +bool AppendableBooleanStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableBooleanStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableBooleanStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool AppendableBooleanStructPubSubType::getKey( const AppendableBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableBooleanStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableBooleanStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void AppendableBooleanStructPubSubType::register_type_object_representation() AppendableOctetStructPubSubType::AppendableOctetStructPubSubType() { - setName("AppendableOctetStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableOctetStruct::getMaxCdrSerializedSize()); -#else - AppendableOctetStruct_max_cdr_typesize; -#endif + set_name("AppendableOctetStruct"); + uint32_t type_size = AppendableOctetStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableOctetStruct_max_key_cdr_typesize > 16 ? AppendableOctetStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableOctetStruct_max_key_cdr_typesize > 16 ? AppendableOctetStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableOctetStructPubSubType::~AppendableOctetStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableOctetStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool AppendableOctetStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableOctetStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool AppendableOctetStructPubSubType::deserialize( AppendableOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool AppendableOctetStructPubSubType::deserialize( return true; } -std::function AppendableOctetStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableOctetStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableOctetStructPubSubType::createData() + 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* AppendableOctetStructPubSubType::create_data() { return reinterpret_cast(new AppendableOctetStruct()); } -void AppendableOctetStructPubSubType::deleteData( +void AppendableOctetStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableOctetStructPubSubType::getKey( +bool AppendableOctetStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableOctetStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableOctetStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool AppendableOctetStructPubSubType::getKey( const AppendableOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableOctetStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableOctetStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void AppendableOctetStructPubSubType::register_type_object_representation() AppendableCharStructPubSubType::AppendableCharStructPubSubType() { - setName("AppendableCharStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableCharStruct::getMaxCdrSerializedSize()); -#else - AppendableCharStruct_max_cdr_typesize; -#endif + set_name("AppendableCharStruct"); + uint32_t type_size = AppendableCharStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableCharStruct_max_key_cdr_typesize > 16 ? AppendableCharStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableCharStruct_max_key_cdr_typesize > 16 ? AppendableCharStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableCharStructPubSubType::~AppendableCharStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableCharStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool AppendableCharStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableCharStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool AppendableCharStructPubSubType::deserialize( AppendableCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool AppendableCharStructPubSubType::deserialize( return true; } -std::function AppendableCharStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableCharStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableCharStructPubSubType::createData() + 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* AppendableCharStructPubSubType::create_data() { return reinterpret_cast(new AppendableCharStruct()); } -void AppendableCharStructPubSubType::deleteData( +void AppendableCharStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableCharStructPubSubType::getKey( +bool AppendableCharStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableCharStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableCharStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool AppendableCharStructPubSubType::getKey( const AppendableCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableCharStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableCharStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void AppendableCharStructPubSubType::register_type_object_representation() AppendableWCharStructPubSubType::AppendableWCharStructPubSubType() { - setName("AppendableWCharStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableWCharStruct::getMaxCdrSerializedSize()); -#else - AppendableWCharStruct_max_cdr_typesize; -#endif + set_name("AppendableWCharStruct"); + uint32_t type_size = AppendableWCharStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableWCharStruct_max_key_cdr_typesize > 16 ? AppendableWCharStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableWCharStruct_max_key_cdr_typesize > 16 ? AppendableWCharStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableWCharStructPubSubType::~AppendableWCharStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableWCharStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool AppendableWCharStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableWCharStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool AppendableWCharStructPubSubType::deserialize( AppendableWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,52 +2277,62 @@ bool AppendableWCharStructPubSubType::deserialize( return true; } -std::function AppendableWCharStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableWCharStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableWCharStructPubSubType::createData() + 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* AppendableWCharStructPubSubType::create_data() { return reinterpret_cast(new AppendableWCharStruct()); } -void AppendableWCharStructPubSubType::deleteData( +void AppendableWCharStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableWCharStructPubSubType::getKey( +bool AppendableWCharStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableWCharStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableWCharStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2501,35 +2340,27 @@ bool AppendableWCharStructPubSubType::getKey( const AppendableWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableWCharStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableWCharStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void AppendableWCharStructPubSubType::register_type_object_representation() AppendableUnionStructPubSubType::AppendableUnionStructPubSubType() { - setName("AppendableUnionStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableUnionStruct::getMaxCdrSerializedSize()); -#else - AppendableUnionStruct_max_cdr_typesize; -#endif + set_name("AppendableUnionStruct"); + uint32_t type_size = AppendableUnionStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableUnionStruct_max_key_cdr_typesize > 16 ? AppendableUnionStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableUnionStruct_max_key_cdr_typesize > 16 ? AppendableUnionStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableUnionStructPubSubType::~AppendableUnionStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableUnionStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableUnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool AppendableUnionStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableUnionStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool AppendableUnionStructPubSubType::deserialize( AppendableUnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool AppendableUnionStructPubSubType::deserialize( return true; } -std::function AppendableUnionStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableUnionStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableUnionStructPubSubType::createData() + 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* AppendableUnionStructPubSubType::create_data() { return reinterpret_cast(new AppendableUnionStruct()); } -void AppendableUnionStructPubSubType::deleteData( +void AppendableUnionStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableUnionStructPubSubType::getKey( +bool AppendableUnionStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableUnionStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableUnionStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool AppendableUnionStructPubSubType::getKey( const AppendableUnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableUnionStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableUnionStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void AppendableUnionStructPubSubType::register_type_object_representation() AppendableEmptyStructPubSubType::AppendableEmptyStructPubSubType() { - setName("AppendableEmptyStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableEmptyStruct::getMaxCdrSerializedSize()); -#else - AppendableEmptyStruct_max_cdr_typesize; -#endif + set_name("AppendableEmptyStruct"); + uint32_t type_size = AppendableEmptyStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableEmptyStruct_max_key_cdr_typesize > 16 ? AppendableEmptyStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableEmptyStruct_max_key_cdr_typesize > 16 ? AppendableEmptyStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableEmptyStructPubSubType::~AppendableEmptyStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableEmptyStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool AppendableEmptyStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableEmptyStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool AppendableEmptyStructPubSubType::deserialize( AppendableEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool AppendableEmptyStructPubSubType::deserialize( return true; } -std::function AppendableEmptyStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableEmptyStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableEmptyStructPubSubType::createData() + 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* AppendableEmptyStructPubSubType::create_data() { return reinterpret_cast(new AppendableEmptyStruct()); } -void AppendableEmptyStructPubSubType::deleteData( +void AppendableEmptyStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableEmptyStructPubSubType::getKey( +bool AppendableEmptyStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableEmptyStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableEmptyStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool AppendableEmptyStructPubSubType::getKey( const AppendableEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableEmptyStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableEmptyStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void AppendableEmptyStructPubSubType::register_type_object_representation() AppendableEmptyInheritanceStructPubSubType::AppendableEmptyInheritanceStructPubSubType() { - setName("AppendableEmptyInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableEmptyInheritanceStruct::getMaxCdrSerializedSize()); -#else - AppendableEmptyInheritanceStruct_max_cdr_typesize; -#endif + set_name("AppendableEmptyInheritanceStruct"); + uint32_t type_size = AppendableEmptyInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableEmptyInheritanceStruct_max_key_cdr_typesize > 16 ? AppendableEmptyInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableEmptyInheritanceStruct_max_key_cdr_typesize > 16 ? AppendableEmptyInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableEmptyInheritanceStructPubSubType::~AppendableEmptyInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableEmptyInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool AppendableEmptyInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableEmptyInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool AppendableEmptyInheritanceStructPubSubType::deserialize( AppendableEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool AppendableEmptyInheritanceStructPubSubType::deserialize( return true; } -std::function AppendableEmptyInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableEmptyInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableEmptyInheritanceStructPubSubType::createData() + 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* AppendableEmptyInheritanceStructPubSubType::create_data() { return reinterpret_cast(new AppendableEmptyInheritanceStruct()); } -void AppendableEmptyInheritanceStructPubSubType::deleteData( +void AppendableEmptyInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableEmptyInheritanceStructPubSubType::getKey( +bool AppendableEmptyInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableEmptyInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableEmptyInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool AppendableEmptyInheritanceStructPubSubType::getKey( const AppendableEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableEmptyInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableEmptyInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void AppendableEmptyInheritanceStructPubSubType::register_type_object_representa AppendableInheritanceStructPubSubType::AppendableInheritanceStructPubSubType() { - setName("AppendableInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableInheritanceStruct::getMaxCdrSerializedSize()); -#else - AppendableInheritanceStruct_max_cdr_typesize; -#endif + set_name("AppendableInheritanceStruct"); + uint32_t type_size = AppendableInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableInheritanceStruct_max_key_cdr_typesize > 16 ? AppendableInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableInheritanceStruct_max_key_cdr_typesize > 16 ? AppendableInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableInheritanceStructPubSubType::~AppendableInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool AppendableInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool AppendableInheritanceStructPubSubType::deserialize( AppendableInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool AppendableInheritanceStructPubSubType::deserialize( return true; } -std::function AppendableInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableInheritanceStructPubSubType::createData() + 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* AppendableInheritanceStructPubSubType::create_data() { return reinterpret_cast(new AppendableInheritanceStruct()); } -void AppendableInheritanceStructPubSubType::deleteData( +void AppendableInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableInheritanceStructPubSubType::getKey( +bool AppendableInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool AppendableInheritanceStructPubSubType::getKey( const AppendableInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void AppendableInheritanceStructPubSubType::register_type_object_representation( AppendableInheritanceEmptyStructPubSubType::AppendableInheritanceEmptyStructPubSubType() { - setName("AppendableInheritanceEmptyStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableInheritanceEmptyStruct::getMaxCdrSerializedSize()); -#else - AppendableInheritanceEmptyStruct_max_cdr_typesize; -#endif + set_name("AppendableInheritanceEmptyStruct"); + uint32_t type_size = AppendableInheritanceEmptyStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableInheritanceEmptyStruct_max_key_cdr_typesize > 16 ? AppendableInheritanceEmptyStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableInheritanceEmptyStruct_max_key_cdr_typesize > 16 ? AppendableInheritanceEmptyStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableInheritanceEmptyStructPubSubType::~AppendableInheritanceEmptyStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableInheritanceEmptyStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableInheritanceEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool AppendableInheritanceEmptyStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableInheritanceEmptyStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool AppendableInheritanceEmptyStructPubSubType::deserialize( AppendableInheritanceEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool AppendableInheritanceEmptyStructPubSubType::deserialize( return true; } -std::function AppendableInheritanceEmptyStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableInheritanceEmptyStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableInheritanceEmptyStructPubSubType::createData() + 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* AppendableInheritanceEmptyStructPubSubType::create_data() { return reinterpret_cast(new AppendableInheritanceEmptyStruct()); } -void AppendableInheritanceEmptyStructPubSubType::deleteData( +void AppendableInheritanceEmptyStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableInheritanceEmptyStructPubSubType::getKey( +bool AppendableInheritanceEmptyStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableInheritanceEmptyStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableInheritanceEmptyStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool AppendableInheritanceEmptyStructPubSubType::getKey( const AppendableInheritanceEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableInheritanceEmptyStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableInheritanceEmptyStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void AppendableInheritanceEmptyStructPubSubType::register_type_object_representa AppendableExtensibilityInheritancePubSubType::AppendableExtensibilityInheritancePubSubType() { - setName("AppendableExtensibilityInheritance"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableExtensibilityInheritance::getMaxCdrSerializedSize()); -#else - AppendableExtensibilityInheritance_max_cdr_typesize; -#endif + set_name("AppendableExtensibilityInheritance"); + uint32_t type_size = AppendableExtensibilityInheritance_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableExtensibilityInheritance_max_key_cdr_typesize > 16 ? AppendableExtensibilityInheritance_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableExtensibilityInheritance_max_key_cdr_typesize > 16 ? AppendableExtensibilityInheritance_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableExtensibilityInheritancePubSubType::~AppendableExtensibilityInheritancePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableExtensibilityInheritancePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableExtensibilityInheritance* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool AppendableExtensibilityInheritancePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableExtensibilityInheritancePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool AppendableExtensibilityInheritancePubSubType::deserialize( AppendableExtensibilityInheritance* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool AppendableExtensibilityInheritancePubSubType::deserialize( return true; } -std::function AppendableExtensibilityInheritancePubSubType::getSerializedSizeProvider( +uint32_t AppendableExtensibilityInheritancePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableExtensibilityInheritancePubSubType::createData() + 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* AppendableExtensibilityInheritancePubSubType::create_data() { return reinterpret_cast(new AppendableExtensibilityInheritance()); } -void AppendableExtensibilityInheritancePubSubType::deleteData( +void AppendableExtensibilityInheritancePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableExtensibilityInheritancePubSubType::getKey( +bool AppendableExtensibilityInheritancePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableExtensibilityInheritance data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableExtensibilityInheritancePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool AppendableExtensibilityInheritancePubSubType::getKey( const AppendableExtensibilityInheritance* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableExtensibilityInheritance_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableExtensibilityInheritance_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/appendablePubSubTypes.hpp b/test/dds-types-test/appendablePubSubTypes.hpp index 83db540ff19..b500618d042 100644 --- a/test/dds-types-test/appendablePubSubTypes.hpp +++ b/test/dds-types-test/appendablePubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated appendable is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class AppendableShortStructPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class AppendableShortStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class AppendableShortStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class AppendableUShortStructPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class AppendableUShortStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class AppendableUShortStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -237,38 +217,30 @@ class AppendableLongStructPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -283,10 +255,6 @@ class AppendableLongStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,8 +275,10 @@ class AppendableLongStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -328,38 +298,30 @@ class AppendableULongStructPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -374,10 +336,6 @@ class AppendableULongStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -398,8 +356,10 @@ class AppendableULongStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -419,38 +379,30 @@ class AppendableLongLongStructPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -465,10 +417,6 @@ class AppendableLongLongStructPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -489,8 +437,10 @@ class AppendableLongLongStructPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -510,38 +460,30 @@ class AppendableULongLongStructPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -556,10 +498,6 @@ class AppendableULongLongStructPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -580,8 +518,10 @@ class AppendableULongLongStructPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -601,38 +541,30 @@ class AppendableFloatStructPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -647,10 +579,6 @@ class AppendableFloatStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -671,8 +599,10 @@ class AppendableFloatStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -692,38 +622,30 @@ class AppendableDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -738,10 +660,6 @@ class AppendableDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -762,8 +680,10 @@ class AppendableDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -783,38 +703,30 @@ class AppendableLongDoubleStructPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -829,10 +741,6 @@ class AppendableLongDoubleStructPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -853,8 +761,10 @@ class AppendableLongDoubleStructPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -874,38 +784,30 @@ class AppendableBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -920,10 +822,6 @@ class AppendableBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -944,8 +842,10 @@ class AppendableBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -965,38 +865,30 @@ class AppendableOctetStructPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1011,10 +903,6 @@ class AppendableOctetStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1035,8 +923,10 @@ class AppendableOctetStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1056,38 +946,30 @@ class AppendableCharStructPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1102,10 +984,6 @@ class AppendableCharStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1126,8 +1004,10 @@ class AppendableCharStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1147,38 +1027,30 @@ class AppendableWCharStructPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1193,10 +1065,6 @@ class AppendableWCharStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1217,8 +1085,10 @@ class AppendableWCharStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1238,38 +1108,30 @@ class AppendableUnionStructPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1284,10 +1146,6 @@ class AppendableUnionStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1308,8 +1166,10 @@ class AppendableUnionStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1329,38 +1189,30 @@ class AppendableEmptyStructPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1375,10 +1227,6 @@ class AppendableEmptyStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1399,8 +1247,10 @@ class AppendableEmptyStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1420,38 +1270,30 @@ class AppendableEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1466,10 +1308,6 @@ class AppendableEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1490,8 +1328,10 @@ class AppendableEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1511,38 +1351,30 @@ class AppendableInheritanceStructPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1557,10 +1389,6 @@ class AppendableInheritanceStructPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1581,8 +1409,10 @@ class AppendableInheritanceStructPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1602,38 +1432,30 @@ class AppendableInheritanceEmptyStructPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1648,10 +1470,6 @@ class AppendableInheritanceEmptyStructPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1672,8 +1490,10 @@ class AppendableInheritanceEmptyStructPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1693,38 +1513,30 @@ class AppendableExtensibilityInheritancePubSubType : public eprosima::fastdds::d eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1739,10 +1551,6 @@ class AppendableExtensibilityInheritancePubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1763,8 +1571,10 @@ class AppendableExtensibilityInheritancePubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/arraysPubSubTypes.cxx b/test/dds-types-test/arraysPubSubTypes.cxx index a9f432fe07c..b71eeea0a26 100644 --- a/test/dds-types-test/arraysPubSubTypes.cxx +++ b/test/dds-types-test/arraysPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; ArrayShortPubSubType::ArrayShortPubSubType() { - setName("ArrayShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayShort::getMaxCdrSerializedSize()); -#else - ArrayShort_max_cdr_typesize; -#endif + set_name("ArrayShort"); + uint32_t type_size = ArrayShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayShort_max_key_cdr_typesize > 16 ? ArrayShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayShort_max_key_cdr_typesize > 16 ? ArrayShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayShortPubSubType::~ArrayShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool ArrayShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool ArrayShortPubSubType::deserialize( ArrayShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool ArrayShortPubSubType::deserialize( return true; } -std::function ArrayShortPubSubType::getSerializedSizeProvider( +uint32_t ArrayShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayShortPubSubType::createData() + 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* ArrayShortPubSubType::create_data() { return reinterpret_cast(new ArrayShort()); } -void ArrayShortPubSubType::deleteData( +void ArrayShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayShortPubSubType::getKey( +bool ArrayShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool ArrayShortPubSubType::getKey( const ArrayShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void ArrayShortPubSubType::register_type_object_representation() ArrayUShortPubSubType::ArrayUShortPubSubType() { - setName("ArrayUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayUShort::getMaxCdrSerializedSize()); -#else - ArrayUShort_max_cdr_typesize; -#endif + set_name("ArrayUShort"); + uint32_t type_size = ArrayUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayUShort_max_key_cdr_typesize > 16 ? ArrayUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayUShort_max_key_cdr_typesize > 16 ? ArrayUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayUShortPubSubType::~ArrayUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool ArrayUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool ArrayUShortPubSubType::deserialize( ArrayUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool ArrayUShortPubSubType::deserialize( return true; } -std::function ArrayUShortPubSubType::getSerializedSizeProvider( +uint32_t ArrayUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayUShortPubSubType::createData() + 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* ArrayUShortPubSubType::create_data() { return reinterpret_cast(new ArrayUShort()); } -void ArrayUShortPubSubType::deleteData( +void ArrayUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayUShortPubSubType::getKey( +bool ArrayUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool ArrayUShortPubSubType::getKey( const ArrayUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void ArrayUShortPubSubType::register_type_object_representation() ArrayLongPubSubType::ArrayLongPubSubType() { - setName("ArrayLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayLong::getMaxCdrSerializedSize()); -#else - ArrayLong_max_cdr_typesize; -#endif + set_name("ArrayLong"); + uint32_t type_size = ArrayLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayLong_max_key_cdr_typesize > 16 ? ArrayLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayLong_max_key_cdr_typesize > 16 ? ArrayLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayLongPubSubType::~ArrayLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool ArrayLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool ArrayLongPubSubType::deserialize( ArrayLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool ArrayLongPubSubType::deserialize( return true; } -std::function ArrayLongPubSubType::getSerializedSizeProvider( +uint32_t ArrayLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayLongPubSubType::createData() + 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* ArrayLongPubSubType::create_data() { return reinterpret_cast(new ArrayLong()); } -void ArrayLongPubSubType::deleteData( +void ArrayLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayLongPubSubType::getKey( +bool ArrayLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool ArrayLongPubSubType::getKey( const ArrayLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void ArrayLongPubSubType::register_type_object_representation() ArrayULongPubSubType::ArrayULongPubSubType() { - setName("ArrayULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayULong::getMaxCdrSerializedSize()); -#else - ArrayULong_max_cdr_typesize; -#endif + set_name("ArrayULong"); + uint32_t type_size = ArrayULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayULong_max_key_cdr_typesize > 16 ? ArrayULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayULong_max_key_cdr_typesize > 16 ? ArrayULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayULongPubSubType::~ArrayULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool ArrayULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool ArrayULongPubSubType::deserialize( ArrayULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool ArrayULongPubSubType::deserialize( return true; } -std::function ArrayULongPubSubType::getSerializedSizeProvider( +uint32_t ArrayULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayULongPubSubType::createData() + 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* ArrayULongPubSubType::create_data() { return reinterpret_cast(new ArrayULong()); } -void ArrayULongPubSubType::deleteData( +void ArrayULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayULongPubSubType::getKey( +bool ArrayULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool ArrayULongPubSubType::getKey( const ArrayULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void ArrayULongPubSubType::register_type_object_representation() ArrayLongLongPubSubType::ArrayLongLongPubSubType() { - setName("ArrayLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayLongLong::getMaxCdrSerializedSize()); -#else - ArrayLongLong_max_cdr_typesize; -#endif + set_name("ArrayLongLong"); + uint32_t type_size = ArrayLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayLongLong_max_key_cdr_typesize > 16 ? ArrayLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayLongLong_max_key_cdr_typesize > 16 ? ArrayLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayLongLongPubSubType::~ArrayLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool ArrayLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool ArrayLongLongPubSubType::deserialize( ArrayLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool ArrayLongLongPubSubType::deserialize( return true; } -std::function ArrayLongLongPubSubType::getSerializedSizeProvider( +uint32_t ArrayLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayLongLongPubSubType::createData() + 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* ArrayLongLongPubSubType::create_data() { return reinterpret_cast(new ArrayLongLong()); } -void ArrayLongLongPubSubType::deleteData( +void ArrayLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayLongLongPubSubType::getKey( +bool ArrayLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool ArrayLongLongPubSubType::getKey( const ArrayLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void ArrayLongLongPubSubType::register_type_object_representation() ArrayULongLongPubSubType::ArrayULongLongPubSubType() { - setName("ArrayULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayULongLong::getMaxCdrSerializedSize()); -#else - ArrayULongLong_max_cdr_typesize; -#endif + set_name("ArrayULongLong"); + uint32_t type_size = ArrayULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayULongLong_max_key_cdr_typesize > 16 ? ArrayULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayULongLong_max_key_cdr_typesize > 16 ? ArrayULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayULongLongPubSubType::~ArrayULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool ArrayULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool ArrayULongLongPubSubType::deserialize( ArrayULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool ArrayULongLongPubSubType::deserialize( return true; } -std::function ArrayULongLongPubSubType::getSerializedSizeProvider( +uint32_t ArrayULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayULongLongPubSubType::createData() + 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* ArrayULongLongPubSubType::create_data() { return reinterpret_cast(new ArrayULongLong()); } -void ArrayULongLongPubSubType::deleteData( +void ArrayULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayULongLongPubSubType::getKey( +bool ArrayULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool ArrayULongLongPubSubType::getKey( const ArrayULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void ArrayULongLongPubSubType::register_type_object_representation() ArrayFloatPubSubType::ArrayFloatPubSubType() { - setName("ArrayFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayFloat::getMaxCdrSerializedSize()); -#else - ArrayFloat_max_cdr_typesize; -#endif + set_name("ArrayFloat"); + uint32_t type_size = ArrayFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayFloat_max_key_cdr_typesize > 16 ? ArrayFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayFloat_max_key_cdr_typesize > 16 ? ArrayFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayFloatPubSubType::~ArrayFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool ArrayFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool ArrayFloatPubSubType::deserialize( ArrayFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool ArrayFloatPubSubType::deserialize( return true; } -std::function ArrayFloatPubSubType::getSerializedSizeProvider( +uint32_t ArrayFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayFloatPubSubType::createData() + 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* ArrayFloatPubSubType::create_data() { return reinterpret_cast(new ArrayFloat()); } -void ArrayFloatPubSubType::deleteData( +void ArrayFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayFloatPubSubType::getKey( +bool ArrayFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool ArrayFloatPubSubType::getKey( const ArrayFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void ArrayFloatPubSubType::register_type_object_representation() ArrayDoublePubSubType::ArrayDoublePubSubType() { - setName("ArrayDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayDouble::getMaxCdrSerializedSize()); -#else - ArrayDouble_max_cdr_typesize; -#endif + set_name("ArrayDouble"); + uint32_t type_size = ArrayDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayDouble_max_key_cdr_typesize > 16 ? ArrayDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayDouble_max_key_cdr_typesize > 16 ? ArrayDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayDoublePubSubType::~ArrayDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool ArrayDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool ArrayDoublePubSubType::deserialize( ArrayDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool ArrayDoublePubSubType::deserialize( return true; } -std::function ArrayDoublePubSubType::getSerializedSizeProvider( +uint32_t ArrayDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayDoublePubSubType::createData() + 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* ArrayDoublePubSubType::create_data() { return reinterpret_cast(new ArrayDouble()); } -void ArrayDoublePubSubType::deleteData( +void ArrayDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayDoublePubSubType::getKey( +bool ArrayDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool ArrayDoublePubSubType::getKey( const ArrayDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void ArrayDoublePubSubType::register_type_object_representation() ArrayLongDoublePubSubType::ArrayLongDoublePubSubType() { - setName("ArrayLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayLongDouble::getMaxCdrSerializedSize()); -#else - ArrayLongDouble_max_cdr_typesize; -#endif + set_name("ArrayLongDouble"); + uint32_t type_size = ArrayLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayLongDouble_max_key_cdr_typesize > 16 ? ArrayLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayLongDouble_max_key_cdr_typesize > 16 ? ArrayLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayLongDoublePubSubType::~ArrayLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool ArrayLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool ArrayLongDoublePubSubType::deserialize( ArrayLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool ArrayLongDoublePubSubType::deserialize( return true; } -std::function ArrayLongDoublePubSubType::getSerializedSizeProvider( +uint32_t ArrayLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayLongDoublePubSubType::createData() + 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* ArrayLongDoublePubSubType::create_data() { return reinterpret_cast(new ArrayLongDouble()); } -void ArrayLongDoublePubSubType::deleteData( +void ArrayLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayLongDoublePubSubType::getKey( +bool ArrayLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool ArrayLongDoublePubSubType::getKey( const ArrayLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void ArrayLongDoublePubSubType::register_type_object_representation() ArrayBooleanPubSubType::ArrayBooleanPubSubType() { - setName("ArrayBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayBoolean::getMaxCdrSerializedSize()); -#else - ArrayBoolean_max_cdr_typesize; -#endif + set_name("ArrayBoolean"); + uint32_t type_size = ArrayBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayBoolean_max_key_cdr_typesize > 16 ? ArrayBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayBoolean_max_key_cdr_typesize > 16 ? ArrayBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayBooleanPubSubType::~ArrayBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool ArrayBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool ArrayBooleanPubSubType::deserialize( ArrayBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool ArrayBooleanPubSubType::deserialize( return true; } -std::function ArrayBooleanPubSubType::getSerializedSizeProvider( +uint32_t ArrayBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayBooleanPubSubType::createData() + 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* ArrayBooleanPubSubType::create_data() { return reinterpret_cast(new ArrayBoolean()); } -void ArrayBooleanPubSubType::deleteData( +void ArrayBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayBooleanPubSubType::getKey( +bool ArrayBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool ArrayBooleanPubSubType::getKey( const ArrayBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void ArrayBooleanPubSubType::register_type_object_representation() ArrayOctetPubSubType::ArrayOctetPubSubType() { - setName("ArrayOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayOctet::getMaxCdrSerializedSize()); -#else - ArrayOctet_max_cdr_typesize; -#endif + set_name("ArrayOctet"); + uint32_t type_size = ArrayOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayOctet_max_key_cdr_typesize > 16 ? ArrayOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayOctet_max_key_cdr_typesize > 16 ? ArrayOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayOctetPubSubType::~ArrayOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool ArrayOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool ArrayOctetPubSubType::deserialize( ArrayOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool ArrayOctetPubSubType::deserialize( return true; } -std::function ArrayOctetPubSubType::getSerializedSizeProvider( +uint32_t ArrayOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayOctetPubSubType::createData() + 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* ArrayOctetPubSubType::create_data() { return reinterpret_cast(new ArrayOctet()); } -void ArrayOctetPubSubType::deleteData( +void ArrayOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayOctetPubSubType::getKey( +bool ArrayOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool ArrayOctetPubSubType::getKey( const ArrayOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void ArrayOctetPubSubType::register_type_object_representation() ArrayCharPubSubType::ArrayCharPubSubType() { - setName("ArrayChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayChar::getMaxCdrSerializedSize()); -#else - ArrayChar_max_cdr_typesize; -#endif + set_name("ArrayChar"); + uint32_t type_size = ArrayChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayChar_max_key_cdr_typesize > 16 ? ArrayChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayChar_max_key_cdr_typesize > 16 ? ArrayChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayCharPubSubType::~ArrayCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool ArrayCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool ArrayCharPubSubType::deserialize( ArrayChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool ArrayCharPubSubType::deserialize( return true; } -std::function ArrayCharPubSubType::getSerializedSizeProvider( +uint32_t ArrayCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayCharPubSubType::createData() + 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* ArrayCharPubSubType::create_data() { return reinterpret_cast(new ArrayChar()); } -void ArrayCharPubSubType::deleteData( +void ArrayCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayCharPubSubType::getKey( +bool ArrayCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool ArrayCharPubSubType::getKey( const ArrayChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void ArrayCharPubSubType::register_type_object_representation() ArrayWCharPubSubType::ArrayWCharPubSubType() { - setName("ArrayWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayWChar::getMaxCdrSerializedSize()); -#else - ArrayWChar_max_cdr_typesize; -#endif + set_name("ArrayWChar"); + uint32_t type_size = ArrayWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayWChar_max_key_cdr_typesize > 16 ? ArrayWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayWChar_max_key_cdr_typesize > 16 ? ArrayWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayWCharPubSubType::~ArrayWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool ArrayWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool ArrayWCharPubSubType::deserialize( ArrayWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,88 +2277,90 @@ bool ArrayWCharPubSubType::deserialize( return true; } -std::function ArrayWCharPubSubType::getSerializedSizeProvider( +uint32_t ArrayWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayWCharPubSubType::createData() + 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* ArrayWCharPubSubType::create_data() { return reinterpret_cast(new ArrayWChar()); } -void ArrayWCharPubSubType::deleteData( +void ArrayWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayWCharPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, +bool ArrayWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const ArrayWChar* p_type = static_cast(data); + ArrayWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - ArrayWChar_max_key_cdr_typesize); + return false; +} + +bool ArrayWCharPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const ArrayWChar* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + ArrayWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void ArrayWCharPubSubType::register_type_object_representation() ArrayStringPubSubType::ArrayStringPubSubType() { - setName("ArrayString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayString::getMaxCdrSerializedSize()); -#else - ArrayString_max_cdr_typesize; -#endif + set_name("ArrayString"); + uint32_t type_size = ArrayString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayString_max_key_cdr_typesize > 16 ? ArrayString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayString_max_key_cdr_typesize > 16 ? ArrayString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayStringPubSubType::~ArrayStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool ArrayStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool ArrayStringPubSubType::deserialize( ArrayString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool ArrayStringPubSubType::deserialize( return true; } -std::function ArrayStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayStringPubSubType::createData() + 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* ArrayStringPubSubType::create_data() { return reinterpret_cast(new ArrayString()); } -void ArrayStringPubSubType::deleteData( +void ArrayStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayStringPubSubType::getKey( +bool ArrayStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool ArrayStringPubSubType::getKey( const ArrayString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void ArrayStringPubSubType::register_type_object_representation() ArrayWStringPubSubType::ArrayWStringPubSubType() { - setName("ArrayWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayWString::getMaxCdrSerializedSize()); -#else - ArrayWString_max_cdr_typesize; -#endif + set_name("ArrayWString"); + uint32_t type_size = ArrayWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayWString_max_key_cdr_typesize > 16 ? ArrayWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayWString_max_key_cdr_typesize > 16 ? ArrayWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayWStringPubSubType::~ArrayWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool ArrayWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool ArrayWStringPubSubType::deserialize( ArrayWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool ArrayWStringPubSubType::deserialize( return true; } -std::function ArrayWStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayWStringPubSubType::createData() + 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* ArrayWStringPubSubType::create_data() { return reinterpret_cast(new ArrayWString()); } -void ArrayWStringPubSubType::deleteData( +void ArrayWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayWStringPubSubType::getKey( +bool ArrayWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool ArrayWStringPubSubType::getKey( const ArrayWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void ArrayWStringPubSubType::register_type_object_representation() ArrayBoundedStringPubSubType::ArrayBoundedStringPubSubType() { - setName("ArrayBoundedString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayBoundedString::getMaxCdrSerializedSize()); -#else - ArrayBoundedString_max_cdr_typesize; -#endif + set_name("ArrayBoundedString"); + uint32_t type_size = ArrayBoundedString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayBoundedString_max_key_cdr_typesize > 16 ? ArrayBoundedString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayBoundedString_max_key_cdr_typesize > 16 ? ArrayBoundedString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayBoundedStringPubSubType::~ArrayBoundedStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayBoundedStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool ArrayBoundedStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayBoundedStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool ArrayBoundedStringPubSubType::deserialize( ArrayBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool ArrayBoundedStringPubSubType::deserialize( return true; } -std::function ArrayBoundedStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayBoundedStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayBoundedStringPubSubType::createData() + 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* ArrayBoundedStringPubSubType::create_data() { return reinterpret_cast(new ArrayBoundedString()); } -void ArrayBoundedStringPubSubType::deleteData( +void ArrayBoundedStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayBoundedStringPubSubType::getKey( +bool ArrayBoundedStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayBoundedString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayBoundedStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool ArrayBoundedStringPubSubType::getKey( const ArrayBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayBoundedString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayBoundedString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void ArrayBoundedStringPubSubType::register_type_object_representation() ArrayBoundedWStringPubSubType::ArrayBoundedWStringPubSubType() { - setName("ArrayBoundedWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayBoundedWString::getMaxCdrSerializedSize()); -#else - ArrayBoundedWString_max_cdr_typesize; -#endif + set_name("ArrayBoundedWString"); + uint32_t type_size = ArrayBoundedWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayBoundedWString_max_key_cdr_typesize > 16 ? ArrayBoundedWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayBoundedWString_max_key_cdr_typesize > 16 ? ArrayBoundedWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayBoundedWStringPubSubType::~ArrayBoundedWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayBoundedWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool ArrayBoundedWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayBoundedWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool ArrayBoundedWStringPubSubType::deserialize( ArrayBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool ArrayBoundedWStringPubSubType::deserialize( return true; } -std::function ArrayBoundedWStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayBoundedWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayBoundedWStringPubSubType::createData() + 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* ArrayBoundedWStringPubSubType::create_data() { return reinterpret_cast(new ArrayBoundedWString()); } -void ArrayBoundedWStringPubSubType::deleteData( +void ArrayBoundedWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayBoundedWStringPubSubType::getKey( +bool ArrayBoundedWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayBoundedWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayBoundedWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool ArrayBoundedWStringPubSubType::getKey( const ArrayBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayBoundedWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayBoundedWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void ArrayBoundedWStringPubSubType::register_type_object_representation() ArrayEnumPubSubType::ArrayEnumPubSubType() { - setName("ArrayEnum"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayEnum::getMaxCdrSerializedSize()); -#else - ArrayEnum_max_cdr_typesize; -#endif + set_name("ArrayEnum"); + uint32_t type_size = ArrayEnum_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayEnum_max_key_cdr_typesize > 16 ? ArrayEnum_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayEnum_max_key_cdr_typesize > 16 ? ArrayEnum_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayEnumPubSubType::~ArrayEnumPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayEnumPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool ArrayEnumPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayEnumPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool ArrayEnumPubSubType::deserialize( ArrayEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool ArrayEnumPubSubType::deserialize( return true; } -std::function ArrayEnumPubSubType::getSerializedSizeProvider( +uint32_t ArrayEnumPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayEnumPubSubType::createData() + 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* ArrayEnumPubSubType::create_data() { return reinterpret_cast(new ArrayEnum()); } -void ArrayEnumPubSubType::deleteData( +void ArrayEnumPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayEnumPubSubType::getKey( +bool ArrayEnumPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayEnum data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayEnumPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool ArrayEnumPubSubType::getKey( const ArrayEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayEnum_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayEnum_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void ArrayEnumPubSubType::register_type_object_representation() ArrayBitMaskPubSubType::ArrayBitMaskPubSubType() { - setName("ArrayBitMask"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayBitMask::getMaxCdrSerializedSize()); -#else - ArrayBitMask_max_cdr_typesize; -#endif + set_name("ArrayBitMask"); + uint32_t type_size = ArrayBitMask_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayBitMask_max_key_cdr_typesize > 16 ? ArrayBitMask_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayBitMask_max_key_cdr_typesize > 16 ? ArrayBitMask_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayBitMaskPubSubType::~ArrayBitMaskPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayBitMaskPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool ArrayBitMaskPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayBitMaskPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool ArrayBitMaskPubSubType::deserialize( ArrayBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool ArrayBitMaskPubSubType::deserialize( return true; } -std::function ArrayBitMaskPubSubType::getSerializedSizeProvider( +uint32_t ArrayBitMaskPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayBitMaskPubSubType::createData() + 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* ArrayBitMaskPubSubType::create_data() { return reinterpret_cast(new ArrayBitMask()); } -void ArrayBitMaskPubSubType::deleteData( +void ArrayBitMaskPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayBitMaskPubSubType::getKey( +bool ArrayBitMaskPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayBitMask data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayBitMaskPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool ArrayBitMaskPubSubType::getKey( const ArrayBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayBitMask_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayBitMask_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3700,49 +3453,42 @@ void ArrayBitMaskPubSubType::register_type_object_representation() ArrayAliasPubSubType::ArrayAliasPubSubType() { - setName("ArrayAlias"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayAlias::getMaxCdrSerializedSize()); -#else - ArrayAlias_max_cdr_typesize; -#endif + set_name("ArrayAlias"); + uint32_t type_size = ArrayAlias_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayAlias_max_key_cdr_typesize > 16 ? ArrayAlias_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayAlias_max_key_cdr_typesize > 16 ? ArrayAlias_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayAliasPubSubType::~ArrayAliasPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayAliasPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3757,16 +3503,12 @@ bool ArrayAliasPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayAliasPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3775,18 +3517,14 @@ bool ArrayAliasPubSubType::deserialize( ArrayAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3799,52 +3537,62 @@ bool ArrayAliasPubSubType::deserialize( return true; } -std::function ArrayAliasPubSubType::getSerializedSizeProvider( +uint32_t ArrayAliasPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayAliasPubSubType::createData() + 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* ArrayAliasPubSubType::create_data() { return reinterpret_cast(new ArrayAlias()); } -void ArrayAliasPubSubType::deleteData( +void ArrayAliasPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayAliasPubSubType::getKey( +bool ArrayAliasPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayAlias data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayAliasPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3852,35 +3600,27 @@ bool ArrayAliasPubSubType::getKey( const ArrayAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayAlias_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayAlias_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3893,49 +3633,42 @@ void ArrayAliasPubSubType::register_type_object_representation() ArrayShortArrayPubSubType::ArrayShortArrayPubSubType() { - setName("ArrayShortArray"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayShortArray::getMaxCdrSerializedSize()); -#else - ArrayShortArray_max_cdr_typesize; -#endif + set_name("ArrayShortArray"); + uint32_t type_size = ArrayShortArray_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayShortArray_max_key_cdr_typesize > 16 ? ArrayShortArray_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayShortArray_max_key_cdr_typesize > 16 ? ArrayShortArray_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayShortArrayPubSubType::~ArrayShortArrayPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayShortArrayPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3950,16 +3683,12 @@ bool ArrayShortArrayPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayShortArrayPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3968,18 +3697,14 @@ bool ArrayShortArrayPubSubType::deserialize( ArrayShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3992,52 +3717,62 @@ bool ArrayShortArrayPubSubType::deserialize( return true; } -std::function ArrayShortArrayPubSubType::getSerializedSizeProvider( +uint32_t ArrayShortArrayPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayShortArrayPubSubType::createData() + 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* ArrayShortArrayPubSubType::create_data() { return reinterpret_cast(new ArrayShortArray()); } -void ArrayShortArrayPubSubType::deleteData( +void ArrayShortArrayPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayShortArrayPubSubType::getKey( +bool ArrayShortArrayPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayShortArray data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayShortArrayPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4045,35 +3780,27 @@ bool ArrayShortArrayPubSubType::getKey( const ArrayShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayShortArray_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayShortArray_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4086,49 +3813,42 @@ void ArrayShortArrayPubSubType::register_type_object_representation() ArraySequencePubSubType::ArraySequencePubSubType() { - setName("ArraySequence"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySequence::getMaxCdrSerializedSize()); -#else - ArraySequence_max_cdr_typesize; -#endif + set_name("ArraySequence"); + uint32_t type_size = ArraySequence_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySequence_max_key_cdr_typesize > 16 ? ArraySequence_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySequence_max_key_cdr_typesize > 16 ? ArraySequence_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySequencePubSubType::~ArraySequencePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySequencePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4143,16 +3863,12 @@ bool ArraySequencePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySequencePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4161,18 +3877,14 @@ bool ArraySequencePubSubType::deserialize( ArraySequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4185,52 +3897,62 @@ bool ArraySequencePubSubType::deserialize( return true; } -std::function ArraySequencePubSubType::getSerializedSizeProvider( +uint32_t ArraySequencePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySequencePubSubType::createData() + 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* ArraySequencePubSubType::create_data() { return reinterpret_cast(new ArraySequence()); } -void ArraySequencePubSubType::deleteData( +void ArraySequencePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySequencePubSubType::getKey( +bool ArraySequencePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySequence data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySequencePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4238,35 +3960,27 @@ bool ArraySequencePubSubType::getKey( const ArraySequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySequence_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySequence_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4279,49 +3993,42 @@ void ArraySequencePubSubType::register_type_object_representation() ArrayMapPubSubType::ArrayMapPubSubType() { - setName("ArrayMap"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMap::getMaxCdrSerializedSize()); -#else - ArrayMap_max_cdr_typesize; -#endif + set_name("ArrayMap"); + uint32_t type_size = ArrayMap_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMap_max_key_cdr_typesize > 16 ? ArrayMap_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMap_max_key_cdr_typesize > 16 ? ArrayMap_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMapPubSubType::~ArrayMapPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMapPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4336,16 +4043,12 @@ bool ArrayMapPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMapPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4354,18 +4057,14 @@ bool ArrayMapPubSubType::deserialize( ArrayMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4378,52 +4077,62 @@ bool ArrayMapPubSubType::deserialize( return true; } -std::function ArrayMapPubSubType::getSerializedSizeProvider( +uint32_t ArrayMapPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMapPubSubType::createData() + 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* ArrayMapPubSubType::create_data() { return reinterpret_cast(new ArrayMap()); } -void ArrayMapPubSubType::deleteData( +void ArrayMapPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMapPubSubType::getKey( +bool ArrayMapPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMap data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMapPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4431,35 +4140,27 @@ bool ArrayMapPubSubType::getKey( const ArrayMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMap_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMap_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4472,49 +4173,42 @@ void ArrayMapPubSubType::register_type_object_representation() ArrayUnionPubSubType::ArrayUnionPubSubType() { - setName("ArrayUnion"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayUnion::getMaxCdrSerializedSize()); -#else - ArrayUnion_max_cdr_typesize; -#endif + set_name("ArrayUnion"); + uint32_t type_size = ArrayUnion_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayUnion_max_key_cdr_typesize > 16 ? ArrayUnion_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayUnion_max_key_cdr_typesize > 16 ? ArrayUnion_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayUnionPubSubType::~ArrayUnionPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayUnionPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4529,16 +4223,12 @@ bool ArrayUnionPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayUnionPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4547,18 +4237,14 @@ bool ArrayUnionPubSubType::deserialize( ArrayUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4571,52 +4257,62 @@ bool ArrayUnionPubSubType::deserialize( return true; } -std::function ArrayUnionPubSubType::getSerializedSizeProvider( +uint32_t ArrayUnionPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayUnionPubSubType::createData() + 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* ArrayUnionPubSubType::create_data() { return reinterpret_cast(new ArrayUnion()); } -void ArrayUnionPubSubType::deleteData( +void ArrayUnionPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayUnionPubSubType::getKey( +bool ArrayUnionPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayUnion data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayUnionPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4624,35 +4320,27 @@ bool ArrayUnionPubSubType::getKey( const ArrayUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayUnion_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayUnion_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4665,49 +4353,42 @@ void ArrayUnionPubSubType::register_type_object_representation() ArrayStructurePubSubType::ArrayStructurePubSubType() { - setName("ArrayStructure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayStructure::getMaxCdrSerializedSize()); -#else - ArrayStructure_max_cdr_typesize; -#endif + set_name("ArrayStructure"); + uint32_t type_size = ArrayStructure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayStructure_max_key_cdr_typesize > 16 ? ArrayStructure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayStructure_max_key_cdr_typesize > 16 ? ArrayStructure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayStructurePubSubType::~ArrayStructurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayStructurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4722,16 +4403,12 @@ bool ArrayStructurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayStructurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4740,18 +4417,14 @@ bool ArrayStructurePubSubType::deserialize( ArrayStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4764,52 +4437,62 @@ bool ArrayStructurePubSubType::deserialize( return true; } -std::function ArrayStructurePubSubType::getSerializedSizeProvider( +uint32_t ArrayStructurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayStructurePubSubType::createData() + 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* ArrayStructurePubSubType::create_data() { return reinterpret_cast(new ArrayStructure()); } -void ArrayStructurePubSubType::deleteData( +void ArrayStructurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayStructurePubSubType::getKey( +bool ArrayStructurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayStructure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayStructurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4817,35 +4500,27 @@ bool ArrayStructurePubSubType::getKey( const ArrayStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayStructure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayStructure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4858,49 +4533,42 @@ void ArrayStructurePubSubType::register_type_object_representation() ArrayBitsetPubSubType::ArrayBitsetPubSubType() { - setName("ArrayBitset"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayBitset::getMaxCdrSerializedSize()); -#else - ArrayBitset_max_cdr_typesize; -#endif + set_name("ArrayBitset"); + uint32_t type_size = ArrayBitset_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayBitset_max_key_cdr_typesize > 16 ? ArrayBitset_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayBitset_max_key_cdr_typesize > 16 ? ArrayBitset_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayBitsetPubSubType::~ArrayBitsetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayBitsetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4915,16 +4583,12 @@ bool ArrayBitsetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayBitsetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4933,18 +4597,14 @@ bool ArrayBitsetPubSubType::deserialize( ArrayBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4957,52 +4617,62 @@ bool ArrayBitsetPubSubType::deserialize( return true; } -std::function ArrayBitsetPubSubType::getSerializedSizeProvider( +uint32_t ArrayBitsetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayBitsetPubSubType::createData() -{ - return reinterpret_cast(new ArrayBitset()); -} - -void ArrayBitsetPubSubType::deleteData( + 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* ArrayBitsetPubSubType::create_data() +{ + return reinterpret_cast(new ArrayBitset()); +} + +void ArrayBitsetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayBitsetPubSubType::getKey( +bool ArrayBitsetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayBitset data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayBitsetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5010,35 +4680,27 @@ bool ArrayBitsetPubSubType::getKey( const ArrayBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayBitset_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayBitset_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5051,49 +4713,42 @@ void ArrayBitsetPubSubType::register_type_object_representation() ArrayMultiDimensionShortPubSubType::ArrayMultiDimensionShortPubSubType() { - setName("ArrayMultiDimensionShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionShort::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionShort_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionShort"); + uint32_t type_size = ArrayMultiDimensionShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionShort_max_key_cdr_typesize > 16 ? ArrayMultiDimensionShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionShort_max_key_cdr_typesize > 16 ? ArrayMultiDimensionShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionShortPubSubType::~ArrayMultiDimensionShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5108,16 +4763,12 @@ bool ArrayMultiDimensionShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5126,18 +4777,14 @@ bool ArrayMultiDimensionShortPubSubType::deserialize( ArrayMultiDimensionShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5150,52 +4797,62 @@ bool ArrayMultiDimensionShortPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionShortPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionShortPubSubType::createData() + 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* ArrayMultiDimensionShortPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionShort()); } -void ArrayMultiDimensionShortPubSubType::deleteData( +void ArrayMultiDimensionShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionShortPubSubType::getKey( +bool ArrayMultiDimensionShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5203,35 +4860,27 @@ bool ArrayMultiDimensionShortPubSubType::getKey( const ArrayMultiDimensionShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5244,49 +4893,42 @@ void ArrayMultiDimensionShortPubSubType::register_type_object_representation() ArrayMultiDimensionUShortPubSubType::ArrayMultiDimensionUShortPubSubType() { - setName("ArrayMultiDimensionUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionUShort::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionUShort_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionUShort"); + uint32_t type_size = ArrayMultiDimensionUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionUShort_max_key_cdr_typesize > 16 ? ArrayMultiDimensionUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionUShort_max_key_cdr_typesize > 16 ? ArrayMultiDimensionUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionUShortPubSubType::~ArrayMultiDimensionUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5301,16 +4943,12 @@ bool ArrayMultiDimensionUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5319,18 +4957,14 @@ bool ArrayMultiDimensionUShortPubSubType::deserialize( ArrayMultiDimensionUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5343,52 +4977,62 @@ bool ArrayMultiDimensionUShortPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionUShortPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionUShortPubSubType::createData() + 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* ArrayMultiDimensionUShortPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionUShort()); } -void ArrayMultiDimensionUShortPubSubType::deleteData( +void ArrayMultiDimensionUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionUShortPubSubType::getKey( +bool ArrayMultiDimensionUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5396,35 +5040,27 @@ bool ArrayMultiDimensionUShortPubSubType::getKey( const ArrayMultiDimensionUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5437,49 +5073,42 @@ void ArrayMultiDimensionUShortPubSubType::register_type_object_representation() ArrayMultiDimensionLongPubSubType::ArrayMultiDimensionLongPubSubType() { - setName("ArrayMultiDimensionLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLong::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLong_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLong"); + uint32_t type_size = ArrayMultiDimensionLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLongPubSubType::~ArrayMultiDimensionLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5494,16 +5123,12 @@ bool ArrayMultiDimensionLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5512,18 +5137,14 @@ bool ArrayMultiDimensionLongPubSubType::deserialize( ArrayMultiDimensionLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5536,52 +5157,62 @@ bool ArrayMultiDimensionLongPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLongPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLongPubSubType::createData() + 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* ArrayMultiDimensionLongPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLong()); } -void ArrayMultiDimensionLongPubSubType::deleteData( +void ArrayMultiDimensionLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLongPubSubType::getKey( +bool ArrayMultiDimensionLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5589,35 +5220,27 @@ bool ArrayMultiDimensionLongPubSubType::getKey( const ArrayMultiDimensionLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5630,49 +5253,42 @@ void ArrayMultiDimensionLongPubSubType::register_type_object_representation() ArrayMultiDimensionULongPubSubType::ArrayMultiDimensionULongPubSubType() { - setName("ArrayMultiDimensionULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionULong::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionULong_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionULong"); + uint32_t type_size = ArrayMultiDimensionULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionULong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionULong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionULongPubSubType::~ArrayMultiDimensionULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5687,16 +5303,12 @@ bool ArrayMultiDimensionULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5705,18 +5317,14 @@ bool ArrayMultiDimensionULongPubSubType::deserialize( ArrayMultiDimensionULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5729,52 +5337,62 @@ bool ArrayMultiDimensionULongPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionULongPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionULongPubSubType::createData() + 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* ArrayMultiDimensionULongPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionULong()); } -void ArrayMultiDimensionULongPubSubType::deleteData( +void ArrayMultiDimensionULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionULongPubSubType::getKey( +bool ArrayMultiDimensionULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5782,35 +5400,27 @@ bool ArrayMultiDimensionULongPubSubType::getKey( const ArrayMultiDimensionULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5823,49 +5433,42 @@ void ArrayMultiDimensionULongPubSubType::register_type_object_representation() ArrayMultiDimensionLongLongPubSubType::ArrayMultiDimensionLongLongPubSubType() { - setName("ArrayMultiDimensionLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLongLong::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLongLong_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLongLong"); + uint32_t type_size = ArrayMultiDimensionLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLongLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLongLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLongLongPubSubType::~ArrayMultiDimensionLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5880,16 +5483,12 @@ bool ArrayMultiDimensionLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5898,18 +5497,14 @@ bool ArrayMultiDimensionLongLongPubSubType::deserialize( ArrayMultiDimensionLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5922,52 +5517,62 @@ bool ArrayMultiDimensionLongLongPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLongLongPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLongLongPubSubType::createData() + 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* ArrayMultiDimensionLongLongPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLongLong()); } -void ArrayMultiDimensionLongLongPubSubType::deleteData( +void ArrayMultiDimensionLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLongLongPubSubType::getKey( +bool ArrayMultiDimensionLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5975,35 +5580,27 @@ bool ArrayMultiDimensionLongLongPubSubType::getKey( const ArrayMultiDimensionLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6016,49 +5613,42 @@ void ArrayMultiDimensionLongLongPubSubType::register_type_object_representation( ArrayMultiDimensionULongLongPubSubType::ArrayMultiDimensionULongLongPubSubType() { - setName("ArrayMultiDimensionULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionULongLong::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionULongLong_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionULongLong"); + uint32_t type_size = ArrayMultiDimensionULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionULongLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionULongLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionULongLongPubSubType::~ArrayMultiDimensionULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6073,16 +5663,12 @@ bool ArrayMultiDimensionULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6091,18 +5677,14 @@ bool ArrayMultiDimensionULongLongPubSubType::deserialize( ArrayMultiDimensionULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6115,52 +5697,62 @@ bool ArrayMultiDimensionULongLongPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionULongLongPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionULongLongPubSubType::createData() + 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* ArrayMultiDimensionULongLongPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionULongLong()); } -void ArrayMultiDimensionULongLongPubSubType::deleteData( +void ArrayMultiDimensionULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionULongLongPubSubType::getKey( +bool ArrayMultiDimensionULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6168,35 +5760,27 @@ bool ArrayMultiDimensionULongLongPubSubType::getKey( const ArrayMultiDimensionULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6209,49 +5793,42 @@ void ArrayMultiDimensionULongLongPubSubType::register_type_object_representation ArrayMultiDimensionFloatPubSubType::ArrayMultiDimensionFloatPubSubType() { - setName("ArrayMultiDimensionFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionFloat::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionFloat_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionFloat"); + uint32_t type_size = ArrayMultiDimensionFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionFloat_max_key_cdr_typesize > 16 ? ArrayMultiDimensionFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionFloat_max_key_cdr_typesize > 16 ? ArrayMultiDimensionFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionFloatPubSubType::~ArrayMultiDimensionFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6266,16 +5843,12 @@ bool ArrayMultiDimensionFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6284,18 +5857,14 @@ bool ArrayMultiDimensionFloatPubSubType::deserialize( ArrayMultiDimensionFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6308,52 +5877,62 @@ bool ArrayMultiDimensionFloatPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionFloatPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionFloatPubSubType::createData() + 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* ArrayMultiDimensionFloatPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionFloat()); } -void ArrayMultiDimensionFloatPubSubType::deleteData( +void ArrayMultiDimensionFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionFloatPubSubType::getKey( +bool ArrayMultiDimensionFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6361,35 +5940,27 @@ bool ArrayMultiDimensionFloatPubSubType::getKey( const ArrayMultiDimensionFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6402,49 +5973,42 @@ void ArrayMultiDimensionFloatPubSubType::register_type_object_representation() ArrayMultiDimensionDoublePubSubType::ArrayMultiDimensionDoublePubSubType() { - setName("ArrayMultiDimensionDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionDouble::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionDouble_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionDouble"); + uint32_t type_size = ArrayMultiDimensionDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionDouble_max_key_cdr_typesize > 16 ? ArrayMultiDimensionDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionDouble_max_key_cdr_typesize > 16 ? ArrayMultiDimensionDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionDoublePubSubType::~ArrayMultiDimensionDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6459,16 +6023,12 @@ bool ArrayMultiDimensionDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6477,18 +6037,14 @@ bool ArrayMultiDimensionDoublePubSubType::deserialize( ArrayMultiDimensionDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6501,52 +6057,62 @@ bool ArrayMultiDimensionDoublePubSubType::deserialize( return true; } -std::function ArrayMultiDimensionDoublePubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionDoublePubSubType::createData() + 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* ArrayMultiDimensionDoublePubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionDouble()); } -void ArrayMultiDimensionDoublePubSubType::deleteData( +void ArrayMultiDimensionDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionDoublePubSubType::getKey( +bool ArrayMultiDimensionDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6554,35 +6120,27 @@ bool ArrayMultiDimensionDoublePubSubType::getKey( const ArrayMultiDimensionDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6595,49 +6153,42 @@ void ArrayMultiDimensionDoublePubSubType::register_type_object_representation() ArrayMultiDimensionLongDoublePubSubType::ArrayMultiDimensionLongDoublePubSubType() { - setName("ArrayMultiDimensionLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLongDouble::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLongDouble_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLongDouble"); + uint32_t type_size = ArrayMultiDimensionLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLongDouble_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLongDouble_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLongDoublePubSubType::~ArrayMultiDimensionLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6652,16 +6203,12 @@ bool ArrayMultiDimensionLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6670,18 +6217,14 @@ bool ArrayMultiDimensionLongDoublePubSubType::deserialize( ArrayMultiDimensionLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6694,52 +6237,62 @@ bool ArrayMultiDimensionLongDoublePubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLongDoublePubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLongDoublePubSubType::createData() + 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* ArrayMultiDimensionLongDoublePubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLongDouble()); } -void ArrayMultiDimensionLongDoublePubSubType::deleteData( +void ArrayMultiDimensionLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLongDoublePubSubType::getKey( +bool ArrayMultiDimensionLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6747,35 +6300,27 @@ bool ArrayMultiDimensionLongDoublePubSubType::getKey( const ArrayMultiDimensionLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6788,49 +6333,42 @@ void ArrayMultiDimensionLongDoublePubSubType::register_type_object_representatio ArrayMultiDimensionBooleanPubSubType::ArrayMultiDimensionBooleanPubSubType() { - setName("ArrayMultiDimensionBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionBoolean::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionBoolean_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionBoolean"); + uint32_t type_size = ArrayMultiDimensionBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionBoolean_max_key_cdr_typesize > 16 ? ArrayMultiDimensionBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionBoolean_max_key_cdr_typesize > 16 ? ArrayMultiDimensionBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionBooleanPubSubType::~ArrayMultiDimensionBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6845,16 +6383,12 @@ bool ArrayMultiDimensionBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6863,18 +6397,14 @@ bool ArrayMultiDimensionBooleanPubSubType::deserialize( ArrayMultiDimensionBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6887,52 +6417,62 @@ bool ArrayMultiDimensionBooleanPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionBooleanPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionBooleanPubSubType::createData() + 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* ArrayMultiDimensionBooleanPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionBoolean()); } -void ArrayMultiDimensionBooleanPubSubType::deleteData( +void ArrayMultiDimensionBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionBooleanPubSubType::getKey( +bool ArrayMultiDimensionBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6940,35 +6480,27 @@ bool ArrayMultiDimensionBooleanPubSubType::getKey( const ArrayMultiDimensionBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6981,49 +6513,42 @@ void ArrayMultiDimensionBooleanPubSubType::register_type_object_representation() ArrayMultiDimensionOctetPubSubType::ArrayMultiDimensionOctetPubSubType() { - setName("ArrayMultiDimensionOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionOctet::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionOctet_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionOctet"); + uint32_t type_size = ArrayMultiDimensionOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionOctet_max_key_cdr_typesize > 16 ? ArrayMultiDimensionOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionOctet_max_key_cdr_typesize > 16 ? ArrayMultiDimensionOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionOctetPubSubType::~ArrayMultiDimensionOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7038,16 +6563,12 @@ bool ArrayMultiDimensionOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7056,18 +6577,14 @@ bool ArrayMultiDimensionOctetPubSubType::deserialize( ArrayMultiDimensionOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7080,52 +6597,62 @@ bool ArrayMultiDimensionOctetPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionOctetPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionOctetPubSubType::createData() + 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* ArrayMultiDimensionOctetPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionOctet()); } -void ArrayMultiDimensionOctetPubSubType::deleteData( +void ArrayMultiDimensionOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionOctetPubSubType::getKey( +bool ArrayMultiDimensionOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7133,35 +6660,27 @@ bool ArrayMultiDimensionOctetPubSubType::getKey( const ArrayMultiDimensionOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7174,49 +6693,42 @@ void ArrayMultiDimensionOctetPubSubType::register_type_object_representation() ArrayMultiDimensionCharPubSubType::ArrayMultiDimensionCharPubSubType() { - setName("ArrayMultiDimensionChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionChar::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionChar_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionChar"); + uint32_t type_size = ArrayMultiDimensionChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionChar_max_key_cdr_typesize > 16 ? ArrayMultiDimensionChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionChar_max_key_cdr_typesize > 16 ? ArrayMultiDimensionChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionCharPubSubType::~ArrayMultiDimensionCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7231,16 +6743,12 @@ bool ArrayMultiDimensionCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7249,18 +6757,14 @@ bool ArrayMultiDimensionCharPubSubType::deserialize( ArrayMultiDimensionChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7273,88 +6777,90 @@ bool ArrayMultiDimensionCharPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionCharPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionCharPubSubType::createData() + 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* ArrayMultiDimensionCharPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionChar()); } -void ArrayMultiDimensionCharPubSubType::deleteData( +void ArrayMultiDimensionCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionCharPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, +bool ArrayMultiDimensionCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const ArrayMultiDimensionChar* p_type = static_cast(data); - + ArrayMultiDimensionChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionCharPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const ArrayMultiDimensionChar* p_type = static_cast(data); + // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7367,49 +6873,42 @@ void ArrayMultiDimensionCharPubSubType::register_type_object_representation() ArrayMultiDimensionWCharPubSubType::ArrayMultiDimensionWCharPubSubType() { - setName("ArrayMultiDimensionWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionWChar::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionWChar_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionWChar"); + uint32_t type_size = ArrayMultiDimensionWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionWChar_max_key_cdr_typesize > 16 ? ArrayMultiDimensionWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionWChar_max_key_cdr_typesize > 16 ? ArrayMultiDimensionWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionWCharPubSubType::~ArrayMultiDimensionWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7424,16 +6923,12 @@ bool ArrayMultiDimensionWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7442,18 +6937,14 @@ bool ArrayMultiDimensionWCharPubSubType::deserialize( ArrayMultiDimensionWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7466,52 +6957,62 @@ bool ArrayMultiDimensionWCharPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionWCharPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionWCharPubSubType::createData() + 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* ArrayMultiDimensionWCharPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionWChar()); } -void ArrayMultiDimensionWCharPubSubType::deleteData( +void ArrayMultiDimensionWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionWCharPubSubType::getKey( +bool ArrayMultiDimensionWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7519,35 +7020,27 @@ bool ArrayMultiDimensionWCharPubSubType::getKey( const ArrayMultiDimensionWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7560,49 +7053,42 @@ void ArrayMultiDimensionWCharPubSubType::register_type_object_representation() ArrayMultiDimensionStringPubSubType::ArrayMultiDimensionStringPubSubType() { - setName("ArrayMultiDimensionString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionString::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionString_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionString"); + uint32_t type_size = ArrayMultiDimensionString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionStringPubSubType::~ArrayMultiDimensionStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7617,16 +7103,12 @@ bool ArrayMultiDimensionStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7635,18 +7117,14 @@ bool ArrayMultiDimensionStringPubSubType::deserialize( ArrayMultiDimensionString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7659,52 +7137,62 @@ bool ArrayMultiDimensionStringPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionStringPubSubType::createData() + 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* ArrayMultiDimensionStringPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionString()); } -void ArrayMultiDimensionStringPubSubType::deleteData( +void ArrayMultiDimensionStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionStringPubSubType::getKey( +bool ArrayMultiDimensionStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7712,35 +7200,27 @@ bool ArrayMultiDimensionStringPubSubType::getKey( const ArrayMultiDimensionString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7753,49 +7233,42 @@ void ArrayMultiDimensionStringPubSubType::register_type_object_representation() ArrayMultiDimensionWStringPubSubType::ArrayMultiDimensionWStringPubSubType() { - setName("ArrayMultiDimensionWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionWString::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionWString_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionWString"); + uint32_t type_size = ArrayMultiDimensionWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionWString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionWString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionWStringPubSubType::~ArrayMultiDimensionWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7810,16 +7283,12 @@ bool ArrayMultiDimensionWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7828,18 +7297,14 @@ bool ArrayMultiDimensionWStringPubSubType::deserialize( ArrayMultiDimensionWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7852,52 +7317,62 @@ bool ArrayMultiDimensionWStringPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionWStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionWStringPubSubType::createData() + 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* ArrayMultiDimensionWStringPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionWString()); } -void ArrayMultiDimensionWStringPubSubType::deleteData( +void ArrayMultiDimensionWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionWStringPubSubType::getKey( +bool ArrayMultiDimensionWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7905,35 +7380,27 @@ bool ArrayMultiDimensionWStringPubSubType::getKey( const ArrayMultiDimensionWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7946,49 +7413,42 @@ void ArrayMultiDimensionWStringPubSubType::register_type_object_representation() ArrayMultiDimensionBoundedStringPubSubType::ArrayMultiDimensionBoundedStringPubSubType() { - setName("ArrayMultiDimensionBoundedString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionBoundedString::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionBoundedString_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionBoundedString"); + uint32_t type_size = ArrayMultiDimensionBoundedString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionBoundedString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionBoundedString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionBoundedString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionBoundedString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionBoundedStringPubSubType::~ArrayMultiDimensionBoundedStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionBoundedStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8003,16 +7463,12 @@ bool ArrayMultiDimensionBoundedStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionBoundedStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8021,18 +7477,14 @@ bool ArrayMultiDimensionBoundedStringPubSubType::deserialize( ArrayMultiDimensionBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8045,52 +7497,62 @@ bool ArrayMultiDimensionBoundedStringPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionBoundedStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionBoundedStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionBoundedStringPubSubType::createData() + 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* ArrayMultiDimensionBoundedStringPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionBoundedString()); } -void ArrayMultiDimensionBoundedStringPubSubType::deleteData( +void ArrayMultiDimensionBoundedStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionBoundedStringPubSubType::getKey( +bool ArrayMultiDimensionBoundedStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionBoundedString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionBoundedStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8098,35 +7560,27 @@ bool ArrayMultiDimensionBoundedStringPubSubType::getKey( const ArrayMultiDimensionBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionBoundedString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionBoundedString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8139,49 +7593,42 @@ void ArrayMultiDimensionBoundedStringPubSubType::register_type_object_representa ArrayMultiDimensionBoundedWStringPubSubType::ArrayMultiDimensionBoundedWStringPubSubType() { - setName("ArrayMultiDimensionBoundedWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionBoundedWString::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionBoundedWString_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionBoundedWString"); + uint32_t type_size = ArrayMultiDimensionBoundedWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionBoundedWString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionBoundedWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionBoundedWString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionBoundedWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionBoundedWStringPubSubType::~ArrayMultiDimensionBoundedWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionBoundedWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8196,16 +7643,12 @@ bool ArrayMultiDimensionBoundedWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionBoundedWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8214,18 +7657,14 @@ bool ArrayMultiDimensionBoundedWStringPubSubType::deserialize( ArrayMultiDimensionBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8238,52 +7677,62 @@ bool ArrayMultiDimensionBoundedWStringPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionBoundedWStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionBoundedWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionBoundedWStringPubSubType::createData() + 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* ArrayMultiDimensionBoundedWStringPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionBoundedWString()); } -void ArrayMultiDimensionBoundedWStringPubSubType::deleteData( +void ArrayMultiDimensionBoundedWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionBoundedWStringPubSubType::getKey( +bool ArrayMultiDimensionBoundedWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionBoundedWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionBoundedWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8291,35 +7740,27 @@ bool ArrayMultiDimensionBoundedWStringPubSubType::getKey( const ArrayMultiDimensionBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionBoundedWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionBoundedWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8332,49 +7773,42 @@ void ArrayMultiDimensionBoundedWStringPubSubType::register_type_object_represent ArrayMultiDimensionEnumPubSubType::ArrayMultiDimensionEnumPubSubType() { - setName("ArrayMultiDimensionEnum"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionEnum::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionEnum_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionEnum"); + uint32_t type_size = ArrayMultiDimensionEnum_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionEnum_max_key_cdr_typesize > 16 ? ArrayMultiDimensionEnum_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionEnum_max_key_cdr_typesize > 16 ? ArrayMultiDimensionEnum_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionEnumPubSubType::~ArrayMultiDimensionEnumPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionEnumPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8389,16 +7823,12 @@ bool ArrayMultiDimensionEnumPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionEnumPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8407,18 +7837,14 @@ bool ArrayMultiDimensionEnumPubSubType::deserialize( ArrayMultiDimensionEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8431,52 +7857,62 @@ bool ArrayMultiDimensionEnumPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionEnumPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionEnumPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionEnumPubSubType::createData() + 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* ArrayMultiDimensionEnumPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionEnum()); } -void ArrayMultiDimensionEnumPubSubType::deleteData( +void ArrayMultiDimensionEnumPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionEnumPubSubType::getKey( +bool ArrayMultiDimensionEnumPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionEnum data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionEnumPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8484,35 +7920,27 @@ bool ArrayMultiDimensionEnumPubSubType::getKey( const ArrayMultiDimensionEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionEnum_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionEnum_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8525,49 +7953,42 @@ void ArrayMultiDimensionEnumPubSubType::register_type_object_representation() ArrayMultiDimensionBitMaskPubSubType::ArrayMultiDimensionBitMaskPubSubType() { - setName("ArrayMultiDimensionBitMask"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionBitMask::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionBitMask_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionBitMask"); + uint32_t type_size = ArrayMultiDimensionBitMask_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionBitMask_max_key_cdr_typesize > 16 ? ArrayMultiDimensionBitMask_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionBitMask_max_key_cdr_typesize > 16 ? ArrayMultiDimensionBitMask_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionBitMaskPubSubType::~ArrayMultiDimensionBitMaskPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionBitMaskPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8582,16 +8003,12 @@ bool ArrayMultiDimensionBitMaskPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionBitMaskPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8600,18 +8017,14 @@ bool ArrayMultiDimensionBitMaskPubSubType::deserialize( ArrayMultiDimensionBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8624,52 +8037,62 @@ bool ArrayMultiDimensionBitMaskPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionBitMaskPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionBitMaskPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionBitMaskPubSubType::createData() + 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* ArrayMultiDimensionBitMaskPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionBitMask()); } -void ArrayMultiDimensionBitMaskPubSubType::deleteData( +void ArrayMultiDimensionBitMaskPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionBitMaskPubSubType::getKey( +bool ArrayMultiDimensionBitMaskPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionBitMask data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionBitMaskPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8677,35 +8100,27 @@ bool ArrayMultiDimensionBitMaskPubSubType::getKey( const ArrayMultiDimensionBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionBitMask_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionBitMask_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8718,49 +8133,42 @@ void ArrayMultiDimensionBitMaskPubSubType::register_type_object_representation() ArrayMultiDimensionAliasPubSubType::ArrayMultiDimensionAliasPubSubType() { - setName("ArrayMultiDimensionAlias"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionAlias::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionAlias_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionAlias"); + uint32_t type_size = ArrayMultiDimensionAlias_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionAlias_max_key_cdr_typesize > 16 ? ArrayMultiDimensionAlias_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionAlias_max_key_cdr_typesize > 16 ? ArrayMultiDimensionAlias_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionAliasPubSubType::~ArrayMultiDimensionAliasPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionAliasPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8775,16 +8183,12 @@ bool ArrayMultiDimensionAliasPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionAliasPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8793,18 +8197,14 @@ bool ArrayMultiDimensionAliasPubSubType::deserialize( ArrayMultiDimensionAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8817,52 +8217,62 @@ bool ArrayMultiDimensionAliasPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionAliasPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionAliasPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionAliasPubSubType::createData() + 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* ArrayMultiDimensionAliasPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionAlias()); } -void ArrayMultiDimensionAliasPubSubType::deleteData( +void ArrayMultiDimensionAliasPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionAliasPubSubType::getKey( +bool ArrayMultiDimensionAliasPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionAlias data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionAliasPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8870,35 +8280,27 @@ bool ArrayMultiDimensionAliasPubSubType::getKey( const ArrayMultiDimensionAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionAlias_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionAlias_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8911,49 +8313,42 @@ void ArrayMultiDimensionAliasPubSubType::register_type_object_representation() ArrayMultiDimensionSequencePubSubType::ArrayMultiDimensionSequencePubSubType() { - setName("ArrayMultiDimensionSequence"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionSequence::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionSequence_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionSequence"); + uint32_t type_size = ArrayMultiDimensionSequence_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionSequence_max_key_cdr_typesize > 16 ? ArrayMultiDimensionSequence_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionSequence_max_key_cdr_typesize > 16 ? ArrayMultiDimensionSequence_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionSequencePubSubType::~ArrayMultiDimensionSequencePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionSequencePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8968,16 +8363,12 @@ bool ArrayMultiDimensionSequencePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionSequencePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8986,18 +8377,14 @@ bool ArrayMultiDimensionSequencePubSubType::deserialize( ArrayMultiDimensionSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9010,52 +8397,62 @@ bool ArrayMultiDimensionSequencePubSubType::deserialize( return true; } -std::function ArrayMultiDimensionSequencePubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionSequencePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionSequencePubSubType::createData() + 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* ArrayMultiDimensionSequencePubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionSequence()); } -void ArrayMultiDimensionSequencePubSubType::deleteData( +void ArrayMultiDimensionSequencePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionSequencePubSubType::getKey( +bool ArrayMultiDimensionSequencePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionSequence data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionSequencePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9063,35 +8460,27 @@ bool ArrayMultiDimensionSequencePubSubType::getKey( const ArrayMultiDimensionSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionSequence_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionSequence_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9104,49 +8493,42 @@ void ArrayMultiDimensionSequencePubSubType::register_type_object_representation( ArrayMultiDimensionMapPubSubType::ArrayMultiDimensionMapPubSubType() { - setName("ArrayMultiDimensionMap"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionMap::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionMap_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionMap"); + uint32_t type_size = ArrayMultiDimensionMap_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionMap_max_key_cdr_typesize > 16 ? ArrayMultiDimensionMap_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionMap_max_key_cdr_typesize > 16 ? ArrayMultiDimensionMap_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionMapPubSubType::~ArrayMultiDimensionMapPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionMapPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9161,16 +8543,12 @@ bool ArrayMultiDimensionMapPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionMapPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9179,18 +8557,14 @@ bool ArrayMultiDimensionMapPubSubType::deserialize( ArrayMultiDimensionMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9203,52 +8577,62 @@ bool ArrayMultiDimensionMapPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionMapPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionMapPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionMapPubSubType::createData() + 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* ArrayMultiDimensionMapPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionMap()); } -void ArrayMultiDimensionMapPubSubType::deleteData( +void ArrayMultiDimensionMapPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionMapPubSubType::getKey( +bool ArrayMultiDimensionMapPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionMap data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionMapPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9256,35 +8640,27 @@ bool ArrayMultiDimensionMapPubSubType::getKey( const ArrayMultiDimensionMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionMap_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionMap_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9297,49 +8673,42 @@ void ArrayMultiDimensionMapPubSubType::register_type_object_representation() ArrayMultiDimensionUnionPubSubType::ArrayMultiDimensionUnionPubSubType() { - setName("ArrayMultiDimensionUnion"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionUnion::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionUnion_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionUnion"); + uint32_t type_size = ArrayMultiDimensionUnion_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionUnion_max_key_cdr_typesize > 16 ? ArrayMultiDimensionUnion_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionUnion_max_key_cdr_typesize > 16 ? ArrayMultiDimensionUnion_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionUnionPubSubType::~ArrayMultiDimensionUnionPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionUnionPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9354,16 +8723,12 @@ bool ArrayMultiDimensionUnionPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionUnionPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9372,18 +8737,14 @@ bool ArrayMultiDimensionUnionPubSubType::deserialize( ArrayMultiDimensionUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9396,52 +8757,62 @@ bool ArrayMultiDimensionUnionPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionUnionPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionUnionPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionUnionPubSubType::createData() + 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* ArrayMultiDimensionUnionPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionUnion()); } -void ArrayMultiDimensionUnionPubSubType::deleteData( +void ArrayMultiDimensionUnionPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionUnionPubSubType::getKey( +bool ArrayMultiDimensionUnionPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionUnion data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionUnionPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9449,35 +8820,27 @@ bool ArrayMultiDimensionUnionPubSubType::getKey( const ArrayMultiDimensionUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionUnion_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionUnion_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9490,49 +8853,42 @@ void ArrayMultiDimensionUnionPubSubType::register_type_object_representation() ArrayMultiDimensionStructurePubSubType::ArrayMultiDimensionStructurePubSubType() { - setName("ArrayMultiDimensionStructure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionStructure::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionStructure_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionStructure"); + uint32_t type_size = ArrayMultiDimensionStructure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionStructure_max_key_cdr_typesize > 16 ? ArrayMultiDimensionStructure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionStructure_max_key_cdr_typesize > 16 ? ArrayMultiDimensionStructure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionStructurePubSubType::~ArrayMultiDimensionStructurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionStructurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9547,16 +8903,12 @@ bool ArrayMultiDimensionStructurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionStructurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9565,18 +8917,14 @@ bool ArrayMultiDimensionStructurePubSubType::deserialize( ArrayMultiDimensionStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9589,52 +8937,62 @@ bool ArrayMultiDimensionStructurePubSubType::deserialize( return true; } -std::function ArrayMultiDimensionStructurePubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionStructurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionStructurePubSubType::createData() + 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* ArrayMultiDimensionStructurePubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionStructure()); } -void ArrayMultiDimensionStructurePubSubType::deleteData( +void ArrayMultiDimensionStructurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionStructurePubSubType::getKey( +bool ArrayMultiDimensionStructurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionStructure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionStructurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9642,35 +9000,27 @@ bool ArrayMultiDimensionStructurePubSubType::getKey( const ArrayMultiDimensionStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionStructure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionStructure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9683,49 +9033,42 @@ void ArrayMultiDimensionStructurePubSubType::register_type_object_representation ArrayMultiDimensionBitsetPubSubType::ArrayMultiDimensionBitsetPubSubType() { - setName("ArrayMultiDimensionBitset"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionBitset::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionBitset_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionBitset"); + uint32_t type_size = ArrayMultiDimensionBitset_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionBitset_max_key_cdr_typesize > 16 ? ArrayMultiDimensionBitset_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionBitset_max_key_cdr_typesize > 16 ? ArrayMultiDimensionBitset_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionBitsetPubSubType::~ArrayMultiDimensionBitsetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionBitsetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9740,16 +9083,12 @@ bool ArrayMultiDimensionBitsetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionBitsetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9758,18 +9097,14 @@ bool ArrayMultiDimensionBitsetPubSubType::deserialize( ArrayMultiDimensionBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9782,52 +9117,62 @@ bool ArrayMultiDimensionBitsetPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionBitsetPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionBitsetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionBitsetPubSubType::createData() -{ - return reinterpret_cast(new ArrayMultiDimensionBitset()); + 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* ArrayMultiDimensionBitsetPubSubType::create_data() +{ + return reinterpret_cast(new ArrayMultiDimensionBitset()); } -void ArrayMultiDimensionBitsetPubSubType::deleteData( +void ArrayMultiDimensionBitsetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionBitsetPubSubType::getKey( +bool ArrayMultiDimensionBitsetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionBitset data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionBitsetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9835,35 +9180,27 @@ bool ArrayMultiDimensionBitsetPubSubType::getKey( const ArrayMultiDimensionBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionBitset_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionBitset_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9878,49 +9215,42 @@ void ArrayMultiDimensionBitsetPubSubType::register_type_object_representation() ArraySingleDimensionLiteralsShortPubSubType::ArraySingleDimensionLiteralsShortPubSubType() { - setName("ArraySingleDimensionLiteralsShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsShort::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsShort_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsShort"); + uint32_t type_size = ArraySingleDimensionLiteralsShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsShort_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsShort_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsShortPubSubType::~ArraySingleDimensionLiteralsShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9935,16 +9265,12 @@ bool ArraySingleDimensionLiteralsShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9953,18 +9279,14 @@ bool ArraySingleDimensionLiteralsShortPubSubType::deserialize( ArraySingleDimensionLiteralsShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9977,52 +9299,62 @@ bool ArraySingleDimensionLiteralsShortPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsShortPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsShortPubSubType::createData() + 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* ArraySingleDimensionLiteralsShortPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsShort()); } -void ArraySingleDimensionLiteralsShortPubSubType::deleteData( +void ArraySingleDimensionLiteralsShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsShortPubSubType::getKey( +bool ArraySingleDimensionLiteralsShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10030,35 +9362,27 @@ bool ArraySingleDimensionLiteralsShortPubSubType::getKey( const ArraySingleDimensionLiteralsShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10071,49 +9395,42 @@ void ArraySingleDimensionLiteralsShortPubSubType::register_type_object_represent ArraySingleDimensionLiteralsUnsignedShortPubSubType::ArraySingleDimensionLiteralsUnsignedShortPubSubType() { - setName("ArraySingleDimensionLiteralsUnsignedShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsUnsignedShort::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsUnsignedShort_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsUnsignedShort"); + uint32_t type_size = ArraySingleDimensionLiteralsUnsignedShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsUnsignedShort_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsUnsignedShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsUnsignedShort_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsUnsignedShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsUnsignedShortPubSubType::~ArraySingleDimensionLiteralsUnsignedShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsUnsignedShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsUnsignedShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10128,16 +9445,12 @@ bool ArraySingleDimensionLiteralsUnsignedShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsUnsignedShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10146,18 +9459,14 @@ bool ArraySingleDimensionLiteralsUnsignedShortPubSubType::deserialize( ArraySingleDimensionLiteralsUnsignedShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10170,52 +9479,62 @@ bool ArraySingleDimensionLiteralsUnsignedShortPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsUnsignedShortPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsUnsignedShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsUnsignedShortPubSubType::createData() + 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* ArraySingleDimensionLiteralsUnsignedShortPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsUnsignedShort()); } -void ArraySingleDimensionLiteralsUnsignedShortPubSubType::deleteData( +void ArraySingleDimensionLiteralsUnsignedShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsUnsignedShortPubSubType::getKey( +bool ArraySingleDimensionLiteralsUnsignedShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsUnsignedShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsUnsignedShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10223,35 +9542,27 @@ bool ArraySingleDimensionLiteralsUnsignedShortPubSubType::getKey( const ArraySingleDimensionLiteralsUnsignedShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsUnsignedShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsUnsignedShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10264,49 +9575,42 @@ void ArraySingleDimensionLiteralsUnsignedShortPubSubType::register_type_object_r ArraySingleDimensionLiteralsLongPubSubType::ArraySingleDimensionLiteralsLongPubSubType() { - setName("ArraySingleDimensionLiteralsLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsLong::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsLong_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsLong"); + uint32_t type_size = ArraySingleDimensionLiteralsLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsLong_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsLong_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsLongPubSubType::~ArraySingleDimensionLiteralsLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10321,16 +9625,12 @@ bool ArraySingleDimensionLiteralsLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10339,18 +9639,14 @@ bool ArraySingleDimensionLiteralsLongPubSubType::deserialize( ArraySingleDimensionLiteralsLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10363,52 +9659,62 @@ bool ArraySingleDimensionLiteralsLongPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsLongPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsLongPubSubType::createData() + 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* ArraySingleDimensionLiteralsLongPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsLong()); } -void ArraySingleDimensionLiteralsLongPubSubType::deleteData( +void ArraySingleDimensionLiteralsLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsLongPubSubType::getKey( +bool ArraySingleDimensionLiteralsLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10416,35 +9722,27 @@ bool ArraySingleDimensionLiteralsLongPubSubType::getKey( const ArraySingleDimensionLiteralsLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10457,49 +9755,42 @@ void ArraySingleDimensionLiteralsLongPubSubType::register_type_object_representa ArraySingleDimensionLiteralsUnsignedLongPubSubType::ArraySingleDimensionLiteralsUnsignedLongPubSubType() { - setName("ArraySingleDimensionLiteralsUnsignedLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsUnsignedLong::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsUnsignedLong_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsUnsignedLong"); + uint32_t type_size = ArraySingleDimensionLiteralsUnsignedLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsUnsignedLong_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsUnsignedLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsUnsignedLong_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsUnsignedLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsUnsignedLongPubSubType::~ArraySingleDimensionLiteralsUnsignedLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsUnsignedLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsUnsignedLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10514,16 +9805,12 @@ bool ArraySingleDimensionLiteralsUnsignedLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsUnsignedLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10532,18 +9819,14 @@ bool ArraySingleDimensionLiteralsUnsignedLongPubSubType::deserialize( ArraySingleDimensionLiteralsUnsignedLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10556,52 +9839,62 @@ bool ArraySingleDimensionLiteralsUnsignedLongPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsUnsignedLongPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsUnsignedLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsUnsignedLongPubSubType::createData() + 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* ArraySingleDimensionLiteralsUnsignedLongPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsUnsignedLong()); } -void ArraySingleDimensionLiteralsUnsignedLongPubSubType::deleteData( +void ArraySingleDimensionLiteralsUnsignedLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsUnsignedLongPubSubType::getKey( +bool ArraySingleDimensionLiteralsUnsignedLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsUnsignedLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsUnsignedLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10609,35 +9902,27 @@ bool ArraySingleDimensionLiteralsUnsignedLongPubSubType::getKey( const ArraySingleDimensionLiteralsUnsignedLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsUnsignedLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsUnsignedLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10650,49 +9935,42 @@ void ArraySingleDimensionLiteralsUnsignedLongPubSubType::register_type_object_re ArraySingleDimensionLiteralsLongLongPubSubType::ArraySingleDimensionLiteralsLongLongPubSubType() { - setName("ArraySingleDimensionLiteralsLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsLongLong::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsLongLong_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsLongLong"); + uint32_t type_size = ArraySingleDimensionLiteralsLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsLongLong_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsLongLong_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsLongLongPubSubType::~ArraySingleDimensionLiteralsLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10707,16 +9985,12 @@ bool ArraySingleDimensionLiteralsLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10725,18 +9999,14 @@ bool ArraySingleDimensionLiteralsLongLongPubSubType::deserialize( ArraySingleDimensionLiteralsLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10749,52 +10019,62 @@ bool ArraySingleDimensionLiteralsLongLongPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsLongLongPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsLongLongPubSubType::createData() + 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* ArraySingleDimensionLiteralsLongLongPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsLongLong()); } -void ArraySingleDimensionLiteralsLongLongPubSubType::deleteData( +void ArraySingleDimensionLiteralsLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsLongLongPubSubType::getKey( +bool ArraySingleDimensionLiteralsLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10802,35 +10082,27 @@ bool ArraySingleDimensionLiteralsLongLongPubSubType::getKey( const ArraySingleDimensionLiteralsLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10843,49 +10115,42 @@ void ArraySingleDimensionLiteralsLongLongPubSubType::register_type_object_repres ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::ArraySingleDimensionLiteralsUnsignedLongLongPubSubType() { - setName("ArraySingleDimensionLiteralsUnsignedLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsUnsignedLongLong::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsUnsignedLongLong_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsUnsignedLongLong"); + uint32_t type_size = ArraySingleDimensionLiteralsUnsignedLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsUnsignedLongLong_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsUnsignedLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsUnsignedLongLong_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsUnsignedLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::~ArraySingleDimensionLiteralsUnsignedLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsUnsignedLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10900,16 +10165,12 @@ bool ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10918,18 +10179,14 @@ bool ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::deserialize( ArraySingleDimensionLiteralsUnsignedLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10942,52 +10199,62 @@ bool ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::createData() + 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* ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsUnsignedLongLong()); } -void ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::deleteData( +void ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::getKey( +bool ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsUnsignedLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10995,35 +10262,27 @@ bool ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::getKey( const ArraySingleDimensionLiteralsUnsignedLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsUnsignedLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsUnsignedLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11036,49 +10295,42 @@ void ArraySingleDimensionLiteralsUnsignedLongLongPubSubType::register_type_objec ArraySingleDimensionLiteralsFloatPubSubType::ArraySingleDimensionLiteralsFloatPubSubType() { - setName("ArraySingleDimensionLiteralsFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsFloat::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsFloat_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsFloat"); + uint32_t type_size = ArraySingleDimensionLiteralsFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsFloat_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsFloat_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsFloatPubSubType::~ArraySingleDimensionLiteralsFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11093,16 +10345,12 @@ bool ArraySingleDimensionLiteralsFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11111,18 +10359,14 @@ bool ArraySingleDimensionLiteralsFloatPubSubType::deserialize( ArraySingleDimensionLiteralsFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11135,52 +10379,62 @@ bool ArraySingleDimensionLiteralsFloatPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsFloatPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsFloatPubSubType::createData() + 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* ArraySingleDimensionLiteralsFloatPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsFloat()); } -void ArraySingleDimensionLiteralsFloatPubSubType::deleteData( +void ArraySingleDimensionLiteralsFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsFloatPubSubType::getKey( +bool ArraySingleDimensionLiteralsFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11188,35 +10442,27 @@ bool ArraySingleDimensionLiteralsFloatPubSubType::getKey( const ArraySingleDimensionLiteralsFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11229,49 +10475,42 @@ void ArraySingleDimensionLiteralsFloatPubSubType::register_type_object_represent ArraySingleDimensionLiteralsDoublePubSubType::ArraySingleDimensionLiteralsDoublePubSubType() { - setName("ArraySingleDimensionLiteralsDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsDouble::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsDouble_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsDouble"); + uint32_t type_size = ArraySingleDimensionLiteralsDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsDouble_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsDouble_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsDoublePubSubType::~ArraySingleDimensionLiteralsDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11286,16 +10525,12 @@ bool ArraySingleDimensionLiteralsDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11304,18 +10539,14 @@ bool ArraySingleDimensionLiteralsDoublePubSubType::deserialize( ArraySingleDimensionLiteralsDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11328,52 +10559,62 @@ bool ArraySingleDimensionLiteralsDoublePubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsDoublePubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsDoublePubSubType::createData() + 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* ArraySingleDimensionLiteralsDoublePubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsDouble()); } -void ArraySingleDimensionLiteralsDoublePubSubType::deleteData( +void ArraySingleDimensionLiteralsDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsDoublePubSubType::getKey( +bool ArraySingleDimensionLiteralsDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11381,35 +10622,27 @@ bool ArraySingleDimensionLiteralsDoublePubSubType::getKey( const ArraySingleDimensionLiteralsDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11422,49 +10655,42 @@ void ArraySingleDimensionLiteralsDoublePubSubType::register_type_object_represen ArraySingleDimensionLiteralsLongDoublePubSubType::ArraySingleDimensionLiteralsLongDoublePubSubType() { - setName("ArraySingleDimensionLiteralsLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsLongDouble::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsLongDouble_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsLongDouble"); + uint32_t type_size = ArraySingleDimensionLiteralsLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsLongDouble_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsLongDouble_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsLongDoublePubSubType::~ArraySingleDimensionLiteralsLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11479,16 +10705,12 @@ bool ArraySingleDimensionLiteralsLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11497,18 +10719,14 @@ bool ArraySingleDimensionLiteralsLongDoublePubSubType::deserialize( ArraySingleDimensionLiteralsLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11521,52 +10739,62 @@ bool ArraySingleDimensionLiteralsLongDoublePubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsLongDoublePubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsLongDoublePubSubType::createData() + 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* ArraySingleDimensionLiteralsLongDoublePubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsLongDouble()); } -void ArraySingleDimensionLiteralsLongDoublePubSubType::deleteData( +void ArraySingleDimensionLiteralsLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsLongDoublePubSubType::getKey( +bool ArraySingleDimensionLiteralsLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11574,35 +10802,27 @@ bool ArraySingleDimensionLiteralsLongDoublePubSubType::getKey( const ArraySingleDimensionLiteralsLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11615,49 +10835,42 @@ void ArraySingleDimensionLiteralsLongDoublePubSubType::register_type_object_repr ArraySingleDimensionLiteralsBooleanPubSubType::ArraySingleDimensionLiteralsBooleanPubSubType() { - setName("ArraySingleDimensionLiteralsBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsBoolean::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsBoolean_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsBoolean"); + uint32_t type_size = ArraySingleDimensionLiteralsBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsBoolean_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsBoolean_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsBooleanPubSubType::~ArraySingleDimensionLiteralsBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11672,16 +10885,12 @@ bool ArraySingleDimensionLiteralsBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11690,18 +10899,14 @@ bool ArraySingleDimensionLiteralsBooleanPubSubType::deserialize( ArraySingleDimensionLiteralsBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11714,52 +10919,62 @@ bool ArraySingleDimensionLiteralsBooleanPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsBooleanPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsBooleanPubSubType::createData() + 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* ArraySingleDimensionLiteralsBooleanPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsBoolean()); } -void ArraySingleDimensionLiteralsBooleanPubSubType::deleteData( +void ArraySingleDimensionLiteralsBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsBooleanPubSubType::getKey( +bool ArraySingleDimensionLiteralsBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11767,35 +10982,27 @@ bool ArraySingleDimensionLiteralsBooleanPubSubType::getKey( const ArraySingleDimensionLiteralsBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11808,49 +11015,42 @@ void ArraySingleDimensionLiteralsBooleanPubSubType::register_type_object_represe ArraySingleDimensionLiteralsOctetPubSubType::ArraySingleDimensionLiteralsOctetPubSubType() { - setName("ArraySingleDimensionLiteralsOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsOctet::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsOctet_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsOctet"); + uint32_t type_size = ArraySingleDimensionLiteralsOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsOctet_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsOctet_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsOctetPubSubType::~ArraySingleDimensionLiteralsOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11865,16 +11065,12 @@ bool ArraySingleDimensionLiteralsOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11883,18 +11079,14 @@ bool ArraySingleDimensionLiteralsOctetPubSubType::deserialize( ArraySingleDimensionLiteralsOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11907,52 +11099,62 @@ bool ArraySingleDimensionLiteralsOctetPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsOctetPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsOctetPubSubType::createData() + 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* ArraySingleDimensionLiteralsOctetPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsOctet()); } -void ArraySingleDimensionLiteralsOctetPubSubType::deleteData( +void ArraySingleDimensionLiteralsOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsOctetPubSubType::getKey( +bool ArraySingleDimensionLiteralsOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11960,35 +11162,27 @@ bool ArraySingleDimensionLiteralsOctetPubSubType::getKey( const ArraySingleDimensionLiteralsOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12001,49 +11195,42 @@ void ArraySingleDimensionLiteralsOctetPubSubType::register_type_object_represent ArraySingleDimensionLiteralsCharPubSubType::ArraySingleDimensionLiteralsCharPubSubType() { - setName("ArraySingleDimensionLiteralsChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsChar::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsChar_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsChar"); + uint32_t type_size = ArraySingleDimensionLiteralsChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsChar_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsChar_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsCharPubSubType::~ArraySingleDimensionLiteralsCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12058,16 +11245,12 @@ bool ArraySingleDimensionLiteralsCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12076,18 +11259,14 @@ bool ArraySingleDimensionLiteralsCharPubSubType::deserialize( ArraySingleDimensionLiteralsChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12100,88 +11279,90 @@ bool ArraySingleDimensionLiteralsCharPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsCharPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsCharPubSubType::createData() + 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* ArraySingleDimensionLiteralsCharPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsChar()); } -void ArraySingleDimensionLiteralsCharPubSubType::deleteData( +void ArraySingleDimensionLiteralsCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsCharPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, +bool ArraySingleDimensionLiteralsCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const ArraySingleDimensionLiteralsChar* p_type = static_cast(data); + ArraySingleDimensionLiteralsChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + return false; +} + +bool ArraySingleDimensionLiteralsCharPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const ArraySingleDimensionLiteralsChar* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12194,49 +11375,42 @@ void ArraySingleDimensionLiteralsCharPubSubType::register_type_object_representa ArraySingleDimensionLiteralsWCharPubSubType::ArraySingleDimensionLiteralsWCharPubSubType() { - setName("ArraySingleDimensionLiteralsWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsWChar::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsWChar_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsWChar"); + uint32_t type_size = ArraySingleDimensionLiteralsWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsWChar_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsWChar_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsWCharPubSubType::~ArraySingleDimensionLiteralsWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12251,16 +11425,12 @@ bool ArraySingleDimensionLiteralsWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12269,18 +11439,14 @@ bool ArraySingleDimensionLiteralsWCharPubSubType::deserialize( ArraySingleDimensionLiteralsWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12293,52 +11459,62 @@ bool ArraySingleDimensionLiteralsWCharPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsWCharPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsWCharPubSubType::createData() + 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* ArraySingleDimensionLiteralsWCharPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsWChar()); } -void ArraySingleDimensionLiteralsWCharPubSubType::deleteData( +void ArraySingleDimensionLiteralsWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsWCharPubSubType::getKey( +bool ArraySingleDimensionLiteralsWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12346,35 +11522,27 @@ bool ArraySingleDimensionLiteralsWCharPubSubType::getKey( const ArraySingleDimensionLiteralsWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12387,49 +11555,42 @@ void ArraySingleDimensionLiteralsWCharPubSubType::register_type_object_represent ArraySingleDimensionLiteralsStringPubSubType::ArraySingleDimensionLiteralsStringPubSubType() { - setName("ArraySingleDimensionLiteralsString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsString::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsString_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsString"); + uint32_t type_size = ArraySingleDimensionLiteralsString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsString_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsString_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsStringPubSubType::~ArraySingleDimensionLiteralsStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12444,16 +11605,12 @@ bool ArraySingleDimensionLiteralsStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12462,18 +11619,14 @@ bool ArraySingleDimensionLiteralsStringPubSubType::deserialize( ArraySingleDimensionLiteralsString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12486,52 +11639,62 @@ bool ArraySingleDimensionLiteralsStringPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsStringPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsStringPubSubType::createData() + 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* ArraySingleDimensionLiteralsStringPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsString()); } -void ArraySingleDimensionLiteralsStringPubSubType::deleteData( +void ArraySingleDimensionLiteralsStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsStringPubSubType::getKey( +bool ArraySingleDimensionLiteralsStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12539,35 +11702,27 @@ bool ArraySingleDimensionLiteralsStringPubSubType::getKey( const ArraySingleDimensionLiteralsString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12580,49 +11735,42 @@ void ArraySingleDimensionLiteralsStringPubSubType::register_type_object_represen ArraySingleDimensionLiteralsWStringPubSubType::ArraySingleDimensionLiteralsWStringPubSubType() { - setName("ArraySingleDimensionLiteralsWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsWString::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsWString_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsWString"); + uint32_t type_size = ArraySingleDimensionLiteralsWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsWString_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsWString_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsWStringPubSubType::~ArraySingleDimensionLiteralsWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12637,16 +11785,12 @@ bool ArraySingleDimensionLiteralsWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12655,18 +11799,14 @@ bool ArraySingleDimensionLiteralsWStringPubSubType::deserialize( ArraySingleDimensionLiteralsWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12679,52 +11819,62 @@ bool ArraySingleDimensionLiteralsWStringPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsWStringPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsWStringPubSubType::createData() + 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* ArraySingleDimensionLiteralsWStringPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsWString()); } -void ArraySingleDimensionLiteralsWStringPubSubType::deleteData( +void ArraySingleDimensionLiteralsWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsWStringPubSubType::getKey( +bool ArraySingleDimensionLiteralsWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12732,35 +11882,27 @@ bool ArraySingleDimensionLiteralsWStringPubSubType::getKey( const ArraySingleDimensionLiteralsWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12773,49 +11915,42 @@ void ArraySingleDimensionLiteralsWStringPubSubType::register_type_object_represe ArraySingleDimensionLiteralsBoundedStringPubSubType::ArraySingleDimensionLiteralsBoundedStringPubSubType() { - setName("ArraySingleDimensionLiteralsBoundedString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsBoundedString::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsBoundedString_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsBoundedString"); + uint32_t type_size = ArraySingleDimensionLiteralsBoundedString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsBoundedString_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsBoundedString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsBoundedString_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsBoundedString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsBoundedStringPubSubType::~ArraySingleDimensionLiteralsBoundedStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsBoundedStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12830,16 +11965,12 @@ bool ArraySingleDimensionLiteralsBoundedStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsBoundedStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12848,18 +11979,14 @@ bool ArraySingleDimensionLiteralsBoundedStringPubSubType::deserialize( ArraySingleDimensionLiteralsBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12872,52 +11999,62 @@ bool ArraySingleDimensionLiteralsBoundedStringPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsBoundedStringPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsBoundedStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsBoundedStringPubSubType::createData() + 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* ArraySingleDimensionLiteralsBoundedStringPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsBoundedString()); } -void ArraySingleDimensionLiteralsBoundedStringPubSubType::deleteData( +void ArraySingleDimensionLiteralsBoundedStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsBoundedStringPubSubType::getKey( +bool ArraySingleDimensionLiteralsBoundedStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsBoundedString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsBoundedStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12925,35 +12062,27 @@ bool ArraySingleDimensionLiteralsBoundedStringPubSubType::getKey( const ArraySingleDimensionLiteralsBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsBoundedString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsBoundedString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12966,49 +12095,42 @@ void ArraySingleDimensionLiteralsBoundedStringPubSubType::register_type_object_r ArraySingleDimensionLiteralsBoundedWStringPubSubType::ArraySingleDimensionLiteralsBoundedWStringPubSubType() { - setName("ArraySingleDimensionLiteralsBoundedWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsBoundedWString::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsBoundedWString_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsBoundedWString"); + uint32_t type_size = ArraySingleDimensionLiteralsBoundedWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsBoundedWString_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsBoundedWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsBoundedWString_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsBoundedWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsBoundedWStringPubSubType::~ArraySingleDimensionLiteralsBoundedWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsBoundedWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13023,16 +12145,12 @@ bool ArraySingleDimensionLiteralsBoundedWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsBoundedWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13041,18 +12159,14 @@ bool ArraySingleDimensionLiteralsBoundedWStringPubSubType::deserialize( ArraySingleDimensionLiteralsBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13065,52 +12179,62 @@ bool ArraySingleDimensionLiteralsBoundedWStringPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsBoundedWStringPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsBoundedWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsBoundedWStringPubSubType::createData() + 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* ArraySingleDimensionLiteralsBoundedWStringPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsBoundedWString()); } -void ArraySingleDimensionLiteralsBoundedWStringPubSubType::deleteData( +void ArraySingleDimensionLiteralsBoundedWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsBoundedWStringPubSubType::getKey( +bool ArraySingleDimensionLiteralsBoundedWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsBoundedWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsBoundedWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13118,35 +12242,27 @@ bool ArraySingleDimensionLiteralsBoundedWStringPubSubType::getKey( const ArraySingleDimensionLiteralsBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsBoundedWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsBoundedWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13159,49 +12275,42 @@ void ArraySingleDimensionLiteralsBoundedWStringPubSubType::register_type_object_ ArraySingleDimensionLiteralsEnumPubSubType::ArraySingleDimensionLiteralsEnumPubSubType() { - setName("ArraySingleDimensionLiteralsEnum"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsEnum::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsEnum_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsEnum"); + uint32_t type_size = ArraySingleDimensionLiteralsEnum_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsEnum_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsEnum_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsEnum_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsEnum_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsEnumPubSubType::~ArraySingleDimensionLiteralsEnumPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsEnumPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13216,16 +12325,12 @@ bool ArraySingleDimensionLiteralsEnumPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsEnumPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13234,18 +12339,14 @@ bool ArraySingleDimensionLiteralsEnumPubSubType::deserialize( ArraySingleDimensionLiteralsEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13258,52 +12359,62 @@ bool ArraySingleDimensionLiteralsEnumPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsEnumPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsEnumPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsEnumPubSubType::createData() + 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* ArraySingleDimensionLiteralsEnumPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsEnum()); } -void ArraySingleDimensionLiteralsEnumPubSubType::deleteData( +void ArraySingleDimensionLiteralsEnumPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsEnumPubSubType::getKey( +bool ArraySingleDimensionLiteralsEnumPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsEnum data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsEnumPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13311,35 +12422,27 @@ bool ArraySingleDimensionLiteralsEnumPubSubType::getKey( const ArraySingleDimensionLiteralsEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsEnum_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsEnum_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13352,49 +12455,42 @@ void ArraySingleDimensionLiteralsEnumPubSubType::register_type_object_representa ArraySingleDimensionLiteralsBitMaskPubSubType::ArraySingleDimensionLiteralsBitMaskPubSubType() { - setName("ArraySingleDimensionLiteralsBitMask"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsBitMask::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsBitMask_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsBitMask"); + uint32_t type_size = ArraySingleDimensionLiteralsBitMask_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsBitMask_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsBitMask_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsBitMask_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsBitMask_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsBitMaskPubSubType::~ArraySingleDimensionLiteralsBitMaskPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsBitMaskPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13409,16 +12505,12 @@ bool ArraySingleDimensionLiteralsBitMaskPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsBitMaskPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13427,18 +12519,14 @@ bool ArraySingleDimensionLiteralsBitMaskPubSubType::deserialize( ArraySingleDimensionLiteralsBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13451,52 +12539,62 @@ bool ArraySingleDimensionLiteralsBitMaskPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsBitMaskPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsBitMaskPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsBitMaskPubSubType::createData() + 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* ArraySingleDimensionLiteralsBitMaskPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsBitMask()); } -void ArraySingleDimensionLiteralsBitMaskPubSubType::deleteData( +void ArraySingleDimensionLiteralsBitMaskPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsBitMaskPubSubType::getKey( +bool ArraySingleDimensionLiteralsBitMaskPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsBitMask data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsBitMaskPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13504,35 +12602,27 @@ bool ArraySingleDimensionLiteralsBitMaskPubSubType::getKey( const ArraySingleDimensionLiteralsBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsBitMask_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsBitMask_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13545,49 +12635,42 @@ void ArraySingleDimensionLiteralsBitMaskPubSubType::register_type_object_represe ArraySingleDimensionLiteralsAliasPubSubType::ArraySingleDimensionLiteralsAliasPubSubType() { - setName("ArraySingleDimensionLiteralsAlias"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsAlias::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsAlias_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsAlias"); + uint32_t type_size = ArraySingleDimensionLiteralsAlias_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsAlias_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsAlias_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsAlias_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsAlias_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsAliasPubSubType::~ArraySingleDimensionLiteralsAliasPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsAliasPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13602,16 +12685,12 @@ bool ArraySingleDimensionLiteralsAliasPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsAliasPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13620,18 +12699,14 @@ bool ArraySingleDimensionLiteralsAliasPubSubType::deserialize( ArraySingleDimensionLiteralsAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13644,52 +12719,62 @@ bool ArraySingleDimensionLiteralsAliasPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsAliasPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsAliasPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsAliasPubSubType::createData() + 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* ArraySingleDimensionLiteralsAliasPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsAlias()); } -void ArraySingleDimensionLiteralsAliasPubSubType::deleteData( +void ArraySingleDimensionLiteralsAliasPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsAliasPubSubType::getKey( +bool ArraySingleDimensionLiteralsAliasPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsAlias data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsAliasPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13697,35 +12782,27 @@ bool ArraySingleDimensionLiteralsAliasPubSubType::getKey( const ArraySingleDimensionLiteralsAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsAlias_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsAlias_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13738,49 +12815,42 @@ void ArraySingleDimensionLiteralsAliasPubSubType::register_type_object_represent ArraySingleDimensionLiteralsShortArrayPubSubType::ArraySingleDimensionLiteralsShortArrayPubSubType() { - setName("ArraySingleDimensionLiteralsShortArray"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsShortArray::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsShortArray_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsShortArray"); + uint32_t type_size = ArraySingleDimensionLiteralsShortArray_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsShortArray_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsShortArray_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsShortArray_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsShortArray_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsShortArrayPubSubType::~ArraySingleDimensionLiteralsShortArrayPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsShortArrayPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13795,16 +12865,12 @@ bool ArraySingleDimensionLiteralsShortArrayPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsShortArrayPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13813,18 +12879,14 @@ bool ArraySingleDimensionLiteralsShortArrayPubSubType::deserialize( ArraySingleDimensionLiteralsShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13837,52 +12899,62 @@ bool ArraySingleDimensionLiteralsShortArrayPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsShortArrayPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsShortArrayPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsShortArrayPubSubType::createData() + 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* ArraySingleDimensionLiteralsShortArrayPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsShortArray()); } -void ArraySingleDimensionLiteralsShortArrayPubSubType::deleteData( +void ArraySingleDimensionLiteralsShortArrayPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsShortArrayPubSubType::getKey( +bool ArraySingleDimensionLiteralsShortArrayPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsShortArray data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsShortArrayPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13890,35 +12962,27 @@ bool ArraySingleDimensionLiteralsShortArrayPubSubType::getKey( const ArraySingleDimensionLiteralsShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsShortArray_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsShortArray_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13931,49 +12995,42 @@ void ArraySingleDimensionLiteralsShortArrayPubSubType::register_type_object_repr ArraySingleDimensionLiteralsSequencePubSubType::ArraySingleDimensionLiteralsSequencePubSubType() { - setName("ArraySingleDimensionLiteralsSequence"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsSequence::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsSequence_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsSequence"); + uint32_t type_size = ArraySingleDimensionLiteralsSequence_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsSequence_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsSequence_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsSequence_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsSequence_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsSequencePubSubType::~ArraySingleDimensionLiteralsSequencePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsSequencePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13988,16 +13045,12 @@ bool ArraySingleDimensionLiteralsSequencePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsSequencePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14006,18 +13059,14 @@ bool ArraySingleDimensionLiteralsSequencePubSubType::deserialize( ArraySingleDimensionLiteralsSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14030,52 +13079,62 @@ bool ArraySingleDimensionLiteralsSequencePubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsSequencePubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsSequencePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsSequencePubSubType::createData() + 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* ArraySingleDimensionLiteralsSequencePubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsSequence()); } -void ArraySingleDimensionLiteralsSequencePubSubType::deleteData( +void ArraySingleDimensionLiteralsSequencePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsSequencePubSubType::getKey( +bool ArraySingleDimensionLiteralsSequencePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsSequence data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsSequencePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14083,35 +13142,27 @@ bool ArraySingleDimensionLiteralsSequencePubSubType::getKey( const ArraySingleDimensionLiteralsSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsSequence_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsSequence_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14124,49 +13175,42 @@ void ArraySingleDimensionLiteralsSequencePubSubType::register_type_object_repres ArraySingleDimensionLiteralsMapPubSubType::ArraySingleDimensionLiteralsMapPubSubType() { - setName("ArraySingleDimensionLiteralsMap"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsMap::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsMap_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsMap"); + uint32_t type_size = ArraySingleDimensionLiteralsMap_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsMap_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsMap_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsMap_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsMap_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsMapPubSubType::~ArraySingleDimensionLiteralsMapPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsMapPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14181,16 +13225,12 @@ bool ArraySingleDimensionLiteralsMapPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsMapPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14199,18 +13239,14 @@ bool ArraySingleDimensionLiteralsMapPubSubType::deserialize( ArraySingleDimensionLiteralsMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14223,52 +13259,62 @@ bool ArraySingleDimensionLiteralsMapPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsMapPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsMapPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsMapPubSubType::createData() + 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* ArraySingleDimensionLiteralsMapPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsMap()); } -void ArraySingleDimensionLiteralsMapPubSubType::deleteData( +void ArraySingleDimensionLiteralsMapPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsMapPubSubType::getKey( +bool ArraySingleDimensionLiteralsMapPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsMap data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsMapPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14276,35 +13322,27 @@ bool ArraySingleDimensionLiteralsMapPubSubType::getKey( const ArraySingleDimensionLiteralsMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsMap_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsMap_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14317,49 +13355,42 @@ void ArraySingleDimensionLiteralsMapPubSubType::register_type_object_representat ArraySingleDimensionLiteralsUnionPubSubType::ArraySingleDimensionLiteralsUnionPubSubType() { - setName("ArraySingleDimensionLiteralsUnion"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsUnion::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsUnion_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsUnion"); + uint32_t type_size = ArraySingleDimensionLiteralsUnion_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsUnion_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsUnion_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsUnion_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsUnion_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsUnionPubSubType::~ArraySingleDimensionLiteralsUnionPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsUnionPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14374,16 +13405,12 @@ bool ArraySingleDimensionLiteralsUnionPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsUnionPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14392,18 +13419,14 @@ bool ArraySingleDimensionLiteralsUnionPubSubType::deserialize( ArraySingleDimensionLiteralsUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14416,52 +13439,62 @@ bool ArraySingleDimensionLiteralsUnionPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsUnionPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsUnionPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsUnionPubSubType::createData() + 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* ArraySingleDimensionLiteralsUnionPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsUnion()); } -void ArraySingleDimensionLiteralsUnionPubSubType::deleteData( +void ArraySingleDimensionLiteralsUnionPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsUnionPubSubType::getKey( +bool ArraySingleDimensionLiteralsUnionPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsUnion data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsUnionPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14469,35 +13502,27 @@ bool ArraySingleDimensionLiteralsUnionPubSubType::getKey( const ArraySingleDimensionLiteralsUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsUnion_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsUnion_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14510,49 +13535,42 @@ void ArraySingleDimensionLiteralsUnionPubSubType::register_type_object_represent ArraySingleDimensionLiteralsStructurePubSubType::ArraySingleDimensionLiteralsStructurePubSubType() { - setName("ArraySingleDimensionLiteralsStructure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsStructure::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsStructure_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsStructure"); + uint32_t type_size = ArraySingleDimensionLiteralsStructure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsStructure_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsStructure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsStructure_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsStructure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsStructurePubSubType::~ArraySingleDimensionLiteralsStructurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsStructurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14567,16 +13585,12 @@ bool ArraySingleDimensionLiteralsStructurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsStructurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14585,18 +13599,14 @@ bool ArraySingleDimensionLiteralsStructurePubSubType::deserialize( ArraySingleDimensionLiteralsStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14609,52 +13619,62 @@ bool ArraySingleDimensionLiteralsStructurePubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsStructurePubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsStructurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsStructurePubSubType::createData() -{ - return reinterpret_cast(new ArraySingleDimensionLiteralsStructure()); -} - -void ArraySingleDimensionLiteralsStructurePubSubType::deleteData( + 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* ArraySingleDimensionLiteralsStructurePubSubType::create_data() +{ + return reinterpret_cast(new ArraySingleDimensionLiteralsStructure()); +} + +void ArraySingleDimensionLiteralsStructurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsStructurePubSubType::getKey( +bool ArraySingleDimensionLiteralsStructurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsStructure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsStructurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14662,35 +13682,27 @@ bool ArraySingleDimensionLiteralsStructurePubSubType::getKey( const ArraySingleDimensionLiteralsStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsStructure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsStructure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14703,49 +13715,42 @@ void ArraySingleDimensionLiteralsStructurePubSubType::register_type_object_repre ArraySingleDimensionLiteralsBitsetPubSubType::ArraySingleDimensionLiteralsBitsetPubSubType() { - setName("ArraySingleDimensionLiteralsBitset"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArraySingleDimensionLiteralsBitset::getMaxCdrSerializedSize()); -#else - ArraySingleDimensionLiteralsBitset_max_cdr_typesize; -#endif + set_name("ArraySingleDimensionLiteralsBitset"); + uint32_t type_size = ArraySingleDimensionLiteralsBitset_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArraySingleDimensionLiteralsBitset_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsBitset_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArraySingleDimensionLiteralsBitset_max_key_cdr_typesize > 16 ? ArraySingleDimensionLiteralsBitset_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArraySingleDimensionLiteralsBitsetPubSubType::~ArraySingleDimensionLiteralsBitsetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArraySingleDimensionLiteralsBitsetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArraySingleDimensionLiteralsBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14760,16 +13765,12 @@ bool ArraySingleDimensionLiteralsBitsetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArraySingleDimensionLiteralsBitsetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14778,18 +13779,14 @@ bool ArraySingleDimensionLiteralsBitsetPubSubType::deserialize( ArraySingleDimensionLiteralsBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14802,52 +13799,62 @@ bool ArraySingleDimensionLiteralsBitsetPubSubType::deserialize( return true; } -std::function ArraySingleDimensionLiteralsBitsetPubSubType::getSerializedSizeProvider( +uint32_t ArraySingleDimensionLiteralsBitsetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArraySingleDimensionLiteralsBitsetPubSubType::createData() + 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* ArraySingleDimensionLiteralsBitsetPubSubType::create_data() { return reinterpret_cast(new ArraySingleDimensionLiteralsBitset()); } -void ArraySingleDimensionLiteralsBitsetPubSubType::deleteData( +void ArraySingleDimensionLiteralsBitsetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArraySingleDimensionLiteralsBitsetPubSubType::getKey( +bool ArraySingleDimensionLiteralsBitsetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArraySingleDimensionLiteralsBitset data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArraySingleDimensionLiteralsBitsetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14855,35 +13862,27 @@ bool ArraySingleDimensionLiteralsBitsetPubSubType::getKey( const ArraySingleDimensionLiteralsBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArraySingleDimensionLiteralsBitset_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArraySingleDimensionLiteralsBitset_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14896,49 +13895,42 @@ void ArraySingleDimensionLiteralsBitsetPubSubType::register_type_object_represen ArrayMultiDimensionLiteralsShortPubSubType::ArrayMultiDimensionLiteralsShortPubSubType() { - setName("ArrayMultiDimensionLiteralsShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsShort::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsShort_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsShort"); + uint32_t type_size = ArrayMultiDimensionLiteralsShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsShort_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsShort_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsShortPubSubType::~ArrayMultiDimensionLiteralsShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14953,16 +13945,12 @@ bool ArrayMultiDimensionLiteralsShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14971,18 +13959,14 @@ bool ArrayMultiDimensionLiteralsShortPubSubType::deserialize( ArrayMultiDimensionLiteralsShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14995,52 +13979,62 @@ bool ArrayMultiDimensionLiteralsShortPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsShortPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsShortPubSubType::createData() + 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* ArrayMultiDimensionLiteralsShortPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsShort()); } -void ArrayMultiDimensionLiteralsShortPubSubType::deleteData( +void ArrayMultiDimensionLiteralsShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsShortPubSubType::getKey( +bool ArrayMultiDimensionLiteralsShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15048,35 +14042,27 @@ bool ArrayMultiDimensionLiteralsShortPubSubType::getKey( const ArrayMultiDimensionLiteralsShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15089,49 +14075,42 @@ void ArrayMultiDimensionLiteralsShortPubSubType::register_type_object_representa ArrayMultiDimensionLiteralsUShortPubSubType::ArrayMultiDimensionLiteralsUShortPubSubType() { - setName("ArrayMultiDimensionLiteralsUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsUShort::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsUShort_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsUShort"); + uint32_t type_size = ArrayMultiDimensionLiteralsUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsUShort_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsUShort_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsUShortPubSubType::~ArrayMultiDimensionLiteralsUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15146,16 +14125,12 @@ bool ArrayMultiDimensionLiteralsUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15164,18 +14139,14 @@ bool ArrayMultiDimensionLiteralsUShortPubSubType::deserialize( ArrayMultiDimensionLiteralsUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15188,52 +14159,62 @@ bool ArrayMultiDimensionLiteralsUShortPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsUShortPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsUShortPubSubType::createData() + 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* ArrayMultiDimensionLiteralsUShortPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsUShort()); } -void ArrayMultiDimensionLiteralsUShortPubSubType::deleteData( +void ArrayMultiDimensionLiteralsUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsUShortPubSubType::getKey( +bool ArrayMultiDimensionLiteralsUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15241,35 +14222,27 @@ bool ArrayMultiDimensionLiteralsUShortPubSubType::getKey( const ArrayMultiDimensionLiteralsUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15282,49 +14255,42 @@ void ArrayMultiDimensionLiteralsUShortPubSubType::register_type_object_represent ArrayMultiDimensionLiteralsLongPubSubType::ArrayMultiDimensionLiteralsLongPubSubType() { - setName("ArrayMultiDimensionLiteralsLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsLong::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsLong_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsLong"); + uint32_t type_size = ArrayMultiDimensionLiteralsLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsLongPubSubType::~ArrayMultiDimensionLiteralsLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15339,16 +14305,12 @@ bool ArrayMultiDimensionLiteralsLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15357,18 +14319,14 @@ bool ArrayMultiDimensionLiteralsLongPubSubType::deserialize( ArrayMultiDimensionLiteralsLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15381,52 +14339,62 @@ bool ArrayMultiDimensionLiteralsLongPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsLongPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsLongPubSubType::createData() + 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* ArrayMultiDimensionLiteralsLongPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsLong()); } -void ArrayMultiDimensionLiteralsLongPubSubType::deleteData( +void ArrayMultiDimensionLiteralsLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsLongPubSubType::getKey( +bool ArrayMultiDimensionLiteralsLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15434,35 +14402,27 @@ bool ArrayMultiDimensionLiteralsLongPubSubType::getKey( const ArrayMultiDimensionLiteralsLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15475,49 +14435,42 @@ void ArrayMultiDimensionLiteralsLongPubSubType::register_type_object_representat ArrayMultiDimensionLiteralsULongPubSubType::ArrayMultiDimensionLiteralsULongPubSubType() { - setName("ArrayMultiDimensionLiteralsULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsULong::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsULong_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsULong"); + uint32_t type_size = ArrayMultiDimensionLiteralsULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsULong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsULong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsULongPubSubType::~ArrayMultiDimensionLiteralsULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15532,16 +14485,12 @@ bool ArrayMultiDimensionLiteralsULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15550,18 +14499,14 @@ bool ArrayMultiDimensionLiteralsULongPubSubType::deserialize( ArrayMultiDimensionLiteralsULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15574,52 +14519,62 @@ bool ArrayMultiDimensionLiteralsULongPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsULongPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsULongPubSubType::createData() + 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* ArrayMultiDimensionLiteralsULongPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsULong()); } -void ArrayMultiDimensionLiteralsULongPubSubType::deleteData( +void ArrayMultiDimensionLiteralsULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsULongPubSubType::getKey( +bool ArrayMultiDimensionLiteralsULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15627,35 +14582,27 @@ bool ArrayMultiDimensionLiteralsULongPubSubType::getKey( const ArrayMultiDimensionLiteralsULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15668,49 +14615,42 @@ void ArrayMultiDimensionLiteralsULongPubSubType::register_type_object_representa ArrayMultiDimensionLiteralsLongLongPubSubType::ArrayMultiDimensionLiteralsLongLongPubSubType() { - setName("ArrayMultiDimensionLiteralsLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsLongLong::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsLongLong_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsLongLong"); + uint32_t type_size = ArrayMultiDimensionLiteralsLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsLongLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsLongLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsLongLongPubSubType::~ArrayMultiDimensionLiteralsLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15725,16 +14665,12 @@ bool ArrayMultiDimensionLiteralsLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15743,18 +14679,14 @@ bool ArrayMultiDimensionLiteralsLongLongPubSubType::deserialize( ArrayMultiDimensionLiteralsLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15767,52 +14699,62 @@ bool ArrayMultiDimensionLiteralsLongLongPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsLongLongPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsLongLongPubSubType::createData() + 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* ArrayMultiDimensionLiteralsLongLongPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsLongLong()); } -void ArrayMultiDimensionLiteralsLongLongPubSubType::deleteData( +void ArrayMultiDimensionLiteralsLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsLongLongPubSubType::getKey( +bool ArrayMultiDimensionLiteralsLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15820,35 +14762,27 @@ bool ArrayMultiDimensionLiteralsLongLongPubSubType::getKey( const ArrayMultiDimensionLiteralsLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15861,49 +14795,42 @@ void ArrayMultiDimensionLiteralsLongLongPubSubType::register_type_object_represe ArrayMultiDimensionLiteralsULongLongPubSubType::ArrayMultiDimensionLiteralsULongLongPubSubType() { - setName("ArrayMultiDimensionLiteralsULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsULongLong::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsULongLong_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsULongLong"); + uint32_t type_size = ArrayMultiDimensionLiteralsULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsULongLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsULongLong_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsULongLongPubSubType::~ArrayMultiDimensionLiteralsULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15918,16 +14845,12 @@ bool ArrayMultiDimensionLiteralsULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15936,18 +14859,14 @@ bool ArrayMultiDimensionLiteralsULongLongPubSubType::deserialize( ArrayMultiDimensionLiteralsULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15960,52 +14879,62 @@ bool ArrayMultiDimensionLiteralsULongLongPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsULongLongPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsULongLongPubSubType::createData() + 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* ArrayMultiDimensionLiteralsULongLongPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsULongLong()); } -void ArrayMultiDimensionLiteralsULongLongPubSubType::deleteData( +void ArrayMultiDimensionLiteralsULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsULongLongPubSubType::getKey( +bool ArrayMultiDimensionLiteralsULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16013,35 +14942,27 @@ bool ArrayMultiDimensionLiteralsULongLongPubSubType::getKey( const ArrayMultiDimensionLiteralsULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16054,49 +14975,42 @@ void ArrayMultiDimensionLiteralsULongLongPubSubType::register_type_object_repres ArrayMultiDimensionLiteralsFloatPubSubType::ArrayMultiDimensionLiteralsFloatPubSubType() { - setName("ArrayMultiDimensionLiteralsFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsFloat::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsFloat_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsFloat"); + uint32_t type_size = ArrayMultiDimensionLiteralsFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsFloat_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsFloat_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsFloatPubSubType::~ArrayMultiDimensionLiteralsFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16111,16 +15025,12 @@ bool ArrayMultiDimensionLiteralsFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16129,18 +15039,14 @@ bool ArrayMultiDimensionLiteralsFloatPubSubType::deserialize( ArrayMultiDimensionLiteralsFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16153,52 +15059,62 @@ bool ArrayMultiDimensionLiteralsFloatPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsFloatPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsFloatPubSubType::createData() + 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* ArrayMultiDimensionLiteralsFloatPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsFloat()); } -void ArrayMultiDimensionLiteralsFloatPubSubType::deleteData( +void ArrayMultiDimensionLiteralsFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsFloatPubSubType::getKey( +bool ArrayMultiDimensionLiteralsFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16206,35 +15122,27 @@ bool ArrayMultiDimensionLiteralsFloatPubSubType::getKey( const ArrayMultiDimensionLiteralsFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16247,49 +15155,42 @@ void ArrayMultiDimensionLiteralsFloatPubSubType::register_type_object_representa ArrayMultiDimensionLiteralsDoublePubSubType::ArrayMultiDimensionLiteralsDoublePubSubType() { - setName("ArrayMultiDimensionLiteralsDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsDouble::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsDouble_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsDouble"); + uint32_t type_size = ArrayMultiDimensionLiteralsDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsDouble_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsDouble_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsDoublePubSubType::~ArrayMultiDimensionLiteralsDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16304,16 +15205,12 @@ bool ArrayMultiDimensionLiteralsDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16322,18 +15219,14 @@ bool ArrayMultiDimensionLiteralsDoublePubSubType::deserialize( ArrayMultiDimensionLiteralsDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16346,52 +15239,62 @@ bool ArrayMultiDimensionLiteralsDoublePubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsDoublePubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsDoublePubSubType::createData() + 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* ArrayMultiDimensionLiteralsDoublePubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsDouble()); } -void ArrayMultiDimensionLiteralsDoublePubSubType::deleteData( +void ArrayMultiDimensionLiteralsDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsDoublePubSubType::getKey( +bool ArrayMultiDimensionLiteralsDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16399,35 +15302,27 @@ bool ArrayMultiDimensionLiteralsDoublePubSubType::getKey( const ArrayMultiDimensionLiteralsDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16440,49 +15335,42 @@ void ArrayMultiDimensionLiteralsDoublePubSubType::register_type_object_represent ArrayMultiDimensionLiteralsLongDoublePubSubType::ArrayMultiDimensionLiteralsLongDoublePubSubType() { - setName("ArrayMultiDimensionLiteralsLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsLongDouble::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsLongDouble_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsLongDouble"); + uint32_t type_size = ArrayMultiDimensionLiteralsLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsLongDouble_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsLongDouble_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsLongDoublePubSubType::~ArrayMultiDimensionLiteralsLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16497,16 +15385,12 @@ bool ArrayMultiDimensionLiteralsLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16515,18 +15399,14 @@ bool ArrayMultiDimensionLiteralsLongDoublePubSubType::deserialize( ArrayMultiDimensionLiteralsLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16539,52 +15419,62 @@ bool ArrayMultiDimensionLiteralsLongDoublePubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsLongDoublePubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsLongDoublePubSubType::createData() + 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* ArrayMultiDimensionLiteralsLongDoublePubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsLongDouble()); } -void ArrayMultiDimensionLiteralsLongDoublePubSubType::deleteData( +void ArrayMultiDimensionLiteralsLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsLongDoublePubSubType::getKey( +bool ArrayMultiDimensionLiteralsLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16592,35 +15482,27 @@ bool ArrayMultiDimensionLiteralsLongDoublePubSubType::getKey( const ArrayMultiDimensionLiteralsLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16633,49 +15515,42 @@ void ArrayMultiDimensionLiteralsLongDoublePubSubType::register_type_object_repre ArrayMultiDimensionLiteralsBooleanPubSubType::ArrayMultiDimensionLiteralsBooleanPubSubType() { - setName("ArrayMultiDimensionLiteralsBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsBoolean::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsBoolean_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsBoolean"); + uint32_t type_size = ArrayMultiDimensionLiteralsBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsBoolean_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsBoolean_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsBooleanPubSubType::~ArrayMultiDimensionLiteralsBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16690,16 +15565,12 @@ bool ArrayMultiDimensionLiteralsBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16708,18 +15579,14 @@ bool ArrayMultiDimensionLiteralsBooleanPubSubType::deserialize( ArrayMultiDimensionLiteralsBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16732,52 +15599,62 @@ bool ArrayMultiDimensionLiteralsBooleanPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsBooleanPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsBooleanPubSubType::createData() + 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* ArrayMultiDimensionLiteralsBooleanPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsBoolean()); } -void ArrayMultiDimensionLiteralsBooleanPubSubType::deleteData( +void ArrayMultiDimensionLiteralsBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsBooleanPubSubType::getKey( +bool ArrayMultiDimensionLiteralsBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16785,35 +15662,27 @@ bool ArrayMultiDimensionLiteralsBooleanPubSubType::getKey( const ArrayMultiDimensionLiteralsBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16826,49 +15695,42 @@ void ArrayMultiDimensionLiteralsBooleanPubSubType::register_type_object_represen ArrayMultiDimensionLiteralsOctetPubSubType::ArrayMultiDimensionLiteralsOctetPubSubType() { - setName("ArrayMultiDimensionLiteralsOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsOctet::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsOctet_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsOctet"); + uint32_t type_size = ArrayMultiDimensionLiteralsOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsOctet_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsOctet_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsOctetPubSubType::~ArrayMultiDimensionLiteralsOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16883,16 +15745,12 @@ bool ArrayMultiDimensionLiteralsOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16901,18 +15759,14 @@ bool ArrayMultiDimensionLiteralsOctetPubSubType::deserialize( ArrayMultiDimensionLiteralsOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16925,88 +15779,90 @@ bool ArrayMultiDimensionLiteralsOctetPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsOctetPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsOctetPubSubType::createData() + 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* ArrayMultiDimensionLiteralsOctetPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsOctet()); } -void ArrayMultiDimensionLiteralsOctetPubSubType::deleteData( +void ArrayMultiDimensionLiteralsOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsOctetPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, +bool ArrayMultiDimensionLiteralsOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const ArrayMultiDimensionLiteralsOctet* p_type = static_cast(data); - + ArrayMultiDimensionLiteralsOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsOctetPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const ArrayMultiDimensionLiteralsOctet* p_type = static_cast(data); + // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17019,49 +15875,42 @@ void ArrayMultiDimensionLiteralsOctetPubSubType::register_type_object_representa ArrayMultiDimensionLiteralsCharPubSubType::ArrayMultiDimensionLiteralsCharPubSubType() { - setName("ArrayMultiDimensionLiteralsChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsChar::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsChar_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsChar"); + uint32_t type_size = ArrayMultiDimensionLiteralsChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsChar_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsChar_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsCharPubSubType::~ArrayMultiDimensionLiteralsCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17076,16 +15925,12 @@ bool ArrayMultiDimensionLiteralsCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17094,18 +15939,14 @@ bool ArrayMultiDimensionLiteralsCharPubSubType::deserialize( ArrayMultiDimensionLiteralsChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17118,52 +15959,62 @@ bool ArrayMultiDimensionLiteralsCharPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsCharPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsCharPubSubType::createData() + 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* ArrayMultiDimensionLiteralsCharPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsChar()); } -void ArrayMultiDimensionLiteralsCharPubSubType::deleteData( +void ArrayMultiDimensionLiteralsCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsCharPubSubType::getKey( +bool ArrayMultiDimensionLiteralsCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17171,35 +16022,27 @@ bool ArrayMultiDimensionLiteralsCharPubSubType::getKey( const ArrayMultiDimensionLiteralsChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17212,49 +16055,42 @@ void ArrayMultiDimensionLiteralsCharPubSubType::register_type_object_representat ArrayMultiDimensionLiteralsWCharPubSubType::ArrayMultiDimensionLiteralsWCharPubSubType() { - setName("ArrayMultiDimensionLiteralsWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsWChar::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsWChar_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsWChar"); + uint32_t type_size = ArrayMultiDimensionLiteralsWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsWChar_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsWChar_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsWCharPubSubType::~ArrayMultiDimensionLiteralsWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17269,16 +16105,12 @@ bool ArrayMultiDimensionLiteralsWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17287,18 +16119,14 @@ bool ArrayMultiDimensionLiteralsWCharPubSubType::deserialize( ArrayMultiDimensionLiteralsWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17311,52 +16139,62 @@ bool ArrayMultiDimensionLiteralsWCharPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsWCharPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsWCharPubSubType::createData() + 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* ArrayMultiDimensionLiteralsWCharPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsWChar()); } -void ArrayMultiDimensionLiteralsWCharPubSubType::deleteData( +void ArrayMultiDimensionLiteralsWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsWCharPubSubType::getKey( +bool ArrayMultiDimensionLiteralsWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17364,35 +16202,27 @@ bool ArrayMultiDimensionLiteralsWCharPubSubType::getKey( const ArrayMultiDimensionLiteralsWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17405,49 +16235,42 @@ void ArrayMultiDimensionLiteralsWCharPubSubType::register_type_object_representa ArrayMultiDimensionLiteralsStringPubSubType::ArrayMultiDimensionLiteralsStringPubSubType() { - setName("ArrayMultiDimensionLiteralsString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsString::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsString_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsString"); + uint32_t type_size = ArrayMultiDimensionLiteralsString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsStringPubSubType::~ArrayMultiDimensionLiteralsStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17462,16 +16285,12 @@ bool ArrayMultiDimensionLiteralsStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17480,18 +16299,14 @@ bool ArrayMultiDimensionLiteralsStringPubSubType::deserialize( ArrayMultiDimensionLiteralsString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17504,52 +16319,62 @@ bool ArrayMultiDimensionLiteralsStringPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsStringPubSubType::createData() + 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* ArrayMultiDimensionLiteralsStringPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsString()); } -void ArrayMultiDimensionLiteralsStringPubSubType::deleteData( +void ArrayMultiDimensionLiteralsStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsStringPubSubType::getKey( +bool ArrayMultiDimensionLiteralsStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17557,35 +16382,27 @@ bool ArrayMultiDimensionLiteralsStringPubSubType::getKey( const ArrayMultiDimensionLiteralsString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17598,49 +16415,42 @@ void ArrayMultiDimensionLiteralsStringPubSubType::register_type_object_represent ArrayMultiDimensionLiteralsWStringPubSubType::ArrayMultiDimensionLiteralsWStringPubSubType() { - setName("ArrayMultiDimensionLiteralsWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsWString::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsWString_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsWString"); + uint32_t type_size = ArrayMultiDimensionLiteralsWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsWString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsWString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsWStringPubSubType::~ArrayMultiDimensionLiteralsWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17655,16 +16465,12 @@ bool ArrayMultiDimensionLiteralsWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17673,18 +16479,14 @@ bool ArrayMultiDimensionLiteralsWStringPubSubType::deserialize( ArrayMultiDimensionLiteralsWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17697,52 +16499,62 @@ bool ArrayMultiDimensionLiteralsWStringPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsWStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsWStringPubSubType::createData() + 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* ArrayMultiDimensionLiteralsWStringPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsWString()); } -void ArrayMultiDimensionLiteralsWStringPubSubType::deleteData( +void ArrayMultiDimensionLiteralsWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsWStringPubSubType::getKey( +bool ArrayMultiDimensionLiteralsWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17750,35 +16562,27 @@ bool ArrayMultiDimensionLiteralsWStringPubSubType::getKey( const ArrayMultiDimensionLiteralsWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17791,49 +16595,42 @@ void ArrayMultiDimensionLiteralsWStringPubSubType::register_type_object_represen ArrayMultiDimensionLiteralsBoundedStringPubSubType::ArrayMultiDimensionLiteralsBoundedStringPubSubType() { - setName("ArrayMultiDimensionLiteralsBoundedString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsBoundedString::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsBoundedString_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsBoundedString"); + uint32_t type_size = ArrayMultiDimensionLiteralsBoundedString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsBoundedString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsBoundedString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsBoundedString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsBoundedString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsBoundedStringPubSubType::~ArrayMultiDimensionLiteralsBoundedStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsBoundedStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17848,16 +16645,12 @@ bool ArrayMultiDimensionLiteralsBoundedStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsBoundedStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17866,18 +16659,14 @@ bool ArrayMultiDimensionLiteralsBoundedStringPubSubType::deserialize( ArrayMultiDimensionLiteralsBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17890,52 +16679,62 @@ bool ArrayMultiDimensionLiteralsBoundedStringPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsBoundedStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsBoundedStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsBoundedStringPubSubType::createData() + 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* ArrayMultiDimensionLiteralsBoundedStringPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsBoundedString()); } -void ArrayMultiDimensionLiteralsBoundedStringPubSubType::deleteData( +void ArrayMultiDimensionLiteralsBoundedStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsBoundedStringPubSubType::getKey( +bool ArrayMultiDimensionLiteralsBoundedStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsBoundedString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsBoundedStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17943,35 +16742,27 @@ bool ArrayMultiDimensionLiteralsBoundedStringPubSubType::getKey( const ArrayMultiDimensionLiteralsBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsBoundedString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsBoundedString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17984,49 +16775,42 @@ void ArrayMultiDimensionLiteralsBoundedStringPubSubType::register_type_object_re ArrayMultiDimensionLiteralsBoundedWStringPubSubType::ArrayMultiDimensionLiteralsBoundedWStringPubSubType() { - setName("ArrayMultiDimensionLiteralsBoundedWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsBoundedWString::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsBoundedWString_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsBoundedWString"); + uint32_t type_size = ArrayMultiDimensionLiteralsBoundedWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsBoundedWString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsBoundedWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsBoundedWString_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsBoundedWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsBoundedWStringPubSubType::~ArrayMultiDimensionLiteralsBoundedWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsBoundedWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18041,16 +16825,12 @@ bool ArrayMultiDimensionLiteralsBoundedWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsBoundedWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18059,18 +16839,14 @@ bool ArrayMultiDimensionLiteralsBoundedWStringPubSubType::deserialize( ArrayMultiDimensionLiteralsBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18083,52 +16859,62 @@ bool ArrayMultiDimensionLiteralsBoundedWStringPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsBoundedWStringPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsBoundedWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsBoundedWStringPubSubType::createData() + 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* ArrayMultiDimensionLiteralsBoundedWStringPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsBoundedWString()); } -void ArrayMultiDimensionLiteralsBoundedWStringPubSubType::deleteData( +void ArrayMultiDimensionLiteralsBoundedWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsBoundedWStringPubSubType::getKey( +bool ArrayMultiDimensionLiteralsBoundedWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsBoundedWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsBoundedWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18136,35 +16922,27 @@ bool ArrayMultiDimensionLiteralsBoundedWStringPubSubType::getKey( const ArrayMultiDimensionLiteralsBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsBoundedWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsBoundedWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18177,49 +16955,42 @@ void ArrayMultiDimensionLiteralsBoundedWStringPubSubType::register_type_object_r ArrayMultiDimensionLiteralsEnumPubSubType::ArrayMultiDimensionLiteralsEnumPubSubType() { - setName("ArrayMultiDimensionLiteralsEnum"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsEnum::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsEnum_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsEnum"); + uint32_t type_size = ArrayMultiDimensionLiteralsEnum_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsEnum_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsEnum_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsEnum_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsEnum_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsEnumPubSubType::~ArrayMultiDimensionLiteralsEnumPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsEnumPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18234,16 +17005,12 @@ bool ArrayMultiDimensionLiteralsEnumPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsEnumPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18252,18 +17019,14 @@ bool ArrayMultiDimensionLiteralsEnumPubSubType::deserialize( ArrayMultiDimensionLiteralsEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18276,52 +17039,62 @@ bool ArrayMultiDimensionLiteralsEnumPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsEnumPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsEnumPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsEnumPubSubType::createData() + 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* ArrayMultiDimensionLiteralsEnumPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsEnum()); } -void ArrayMultiDimensionLiteralsEnumPubSubType::deleteData( +void ArrayMultiDimensionLiteralsEnumPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsEnumPubSubType::getKey( +bool ArrayMultiDimensionLiteralsEnumPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsEnum data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsEnumPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18329,35 +17102,27 @@ bool ArrayMultiDimensionLiteralsEnumPubSubType::getKey( const ArrayMultiDimensionLiteralsEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsEnum_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsEnum_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18370,49 +17135,42 @@ void ArrayMultiDimensionLiteralsEnumPubSubType::register_type_object_representat ArrayMultiDimensionLiteralsBitMaskPubSubType::ArrayMultiDimensionLiteralsBitMaskPubSubType() { - setName("ArrayMultiDimensionLiteralsBitMask"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsBitMask::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsBitMask_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsBitMask"); + uint32_t type_size = ArrayMultiDimensionLiteralsBitMask_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsBitMask_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsBitMask_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsBitMask_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsBitMask_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsBitMaskPubSubType::~ArrayMultiDimensionLiteralsBitMaskPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsBitMaskPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18427,16 +17185,12 @@ bool ArrayMultiDimensionLiteralsBitMaskPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsBitMaskPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18445,18 +17199,14 @@ bool ArrayMultiDimensionLiteralsBitMaskPubSubType::deserialize( ArrayMultiDimensionLiteralsBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18469,52 +17219,62 @@ bool ArrayMultiDimensionLiteralsBitMaskPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsBitMaskPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsBitMaskPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsBitMaskPubSubType::createData() + 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* ArrayMultiDimensionLiteralsBitMaskPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsBitMask()); } -void ArrayMultiDimensionLiteralsBitMaskPubSubType::deleteData( +void ArrayMultiDimensionLiteralsBitMaskPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsBitMaskPubSubType::getKey( +bool ArrayMultiDimensionLiteralsBitMaskPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsBitMask data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsBitMaskPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18522,35 +17282,27 @@ bool ArrayMultiDimensionLiteralsBitMaskPubSubType::getKey( const ArrayMultiDimensionLiteralsBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsBitMask_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsBitMask_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18563,49 +17315,42 @@ void ArrayMultiDimensionLiteralsBitMaskPubSubType::register_type_object_represen ArrayMultiDimensionLiteralsAliasPubSubType::ArrayMultiDimensionLiteralsAliasPubSubType() { - setName("ArrayMultiDimensionLiteralsAlias"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsAlias::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsAlias_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsAlias"); + uint32_t type_size = ArrayMultiDimensionLiteralsAlias_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsAlias_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsAlias_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsAlias_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsAlias_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsAliasPubSubType::~ArrayMultiDimensionLiteralsAliasPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsAliasPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18620,16 +17365,12 @@ bool ArrayMultiDimensionLiteralsAliasPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsAliasPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18638,18 +17379,14 @@ bool ArrayMultiDimensionLiteralsAliasPubSubType::deserialize( ArrayMultiDimensionLiteralsAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18662,52 +17399,62 @@ bool ArrayMultiDimensionLiteralsAliasPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsAliasPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsAliasPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsAliasPubSubType::createData() + 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* ArrayMultiDimensionLiteralsAliasPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsAlias()); } -void ArrayMultiDimensionLiteralsAliasPubSubType::deleteData( +void ArrayMultiDimensionLiteralsAliasPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsAliasPubSubType::getKey( +bool ArrayMultiDimensionLiteralsAliasPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsAlias data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsAliasPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18715,35 +17462,27 @@ bool ArrayMultiDimensionLiteralsAliasPubSubType::getKey( const ArrayMultiDimensionLiteralsAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsAlias_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsAlias_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18756,49 +17495,42 @@ void ArrayMultiDimensionLiteralsAliasPubSubType::register_type_object_representa ArrayMultiDimensionLiteralsSequencePubSubType::ArrayMultiDimensionLiteralsSequencePubSubType() { - setName("ArrayMultiDimensionLiteralsSequence"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsSequence::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsSequence_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsSequence"); + uint32_t type_size = ArrayMultiDimensionLiteralsSequence_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsSequence_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsSequence_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsSequence_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsSequence_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsSequencePubSubType::~ArrayMultiDimensionLiteralsSequencePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsSequencePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18813,16 +17545,12 @@ bool ArrayMultiDimensionLiteralsSequencePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsSequencePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18831,18 +17559,14 @@ bool ArrayMultiDimensionLiteralsSequencePubSubType::deserialize( ArrayMultiDimensionLiteralsSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18855,52 +17579,62 @@ bool ArrayMultiDimensionLiteralsSequencePubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsSequencePubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsSequencePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsSequencePubSubType::createData() + 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* ArrayMultiDimensionLiteralsSequencePubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsSequence()); } -void ArrayMultiDimensionLiteralsSequencePubSubType::deleteData( +void ArrayMultiDimensionLiteralsSequencePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsSequencePubSubType::getKey( +bool ArrayMultiDimensionLiteralsSequencePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsSequence data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsSequencePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18908,35 +17642,27 @@ bool ArrayMultiDimensionLiteralsSequencePubSubType::getKey( const ArrayMultiDimensionLiteralsSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsSequence_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsSequence_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18949,49 +17675,42 @@ void ArrayMultiDimensionLiteralsSequencePubSubType::register_type_object_represe ArrayMultiDimensionLiteralsMapPubSubType::ArrayMultiDimensionLiteralsMapPubSubType() { - setName("ArrayMultiDimensionLiteralsMap"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsMap::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsMap_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsMap"); + uint32_t type_size = ArrayMultiDimensionLiteralsMap_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsMap_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsMap_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsMap_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsMap_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsMapPubSubType::~ArrayMultiDimensionLiteralsMapPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsMapPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19006,16 +17725,12 @@ bool ArrayMultiDimensionLiteralsMapPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsMapPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19024,18 +17739,14 @@ bool ArrayMultiDimensionLiteralsMapPubSubType::deserialize( ArrayMultiDimensionLiteralsMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -19048,52 +17759,62 @@ bool ArrayMultiDimensionLiteralsMapPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsMapPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsMapPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsMapPubSubType::createData() + 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* ArrayMultiDimensionLiteralsMapPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsMap()); } -void ArrayMultiDimensionLiteralsMapPubSubType::deleteData( +void ArrayMultiDimensionLiteralsMapPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsMapPubSubType::getKey( +bool ArrayMultiDimensionLiteralsMapPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsMap data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsMapPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -19101,35 +17822,27 @@ bool ArrayMultiDimensionLiteralsMapPubSubType::getKey( const ArrayMultiDimensionLiteralsMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsMap_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsMap_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -19142,49 +17855,42 @@ void ArrayMultiDimensionLiteralsMapPubSubType::register_type_object_representati ArrayMultiDimensionLiteralsUnionPubSubType::ArrayMultiDimensionLiteralsUnionPubSubType() { - setName("ArrayMultiDimensionLiteralsUnion"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsUnion::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsUnion_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsUnion"); + uint32_t type_size = ArrayMultiDimensionLiteralsUnion_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsUnion_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsUnion_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsUnion_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsUnion_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsUnionPubSubType::~ArrayMultiDimensionLiteralsUnionPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsUnionPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19199,16 +17905,12 @@ bool ArrayMultiDimensionLiteralsUnionPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsUnionPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19217,18 +17919,14 @@ bool ArrayMultiDimensionLiteralsUnionPubSubType::deserialize( ArrayMultiDimensionLiteralsUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -19241,52 +17939,62 @@ bool ArrayMultiDimensionLiteralsUnionPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsUnionPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsUnionPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsUnionPubSubType::createData() + 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* ArrayMultiDimensionLiteralsUnionPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsUnion()); } -void ArrayMultiDimensionLiteralsUnionPubSubType::deleteData( +void ArrayMultiDimensionLiteralsUnionPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsUnionPubSubType::getKey( +bool ArrayMultiDimensionLiteralsUnionPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsUnion data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsUnionPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -19294,35 +18002,27 @@ bool ArrayMultiDimensionLiteralsUnionPubSubType::getKey( const ArrayMultiDimensionLiteralsUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsUnion_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsUnion_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -19335,49 +18035,42 @@ void ArrayMultiDimensionLiteralsUnionPubSubType::register_type_object_representa ArrayMultiDimensionLiteralsStructurePubSubType::ArrayMultiDimensionLiteralsStructurePubSubType() { - setName("ArrayMultiDimensionLiteralsStructure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsStructure::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsStructure_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsStructure"); + uint32_t type_size = ArrayMultiDimensionLiteralsStructure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsStructure_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsStructure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsStructure_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsStructure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsStructurePubSubType::~ArrayMultiDimensionLiteralsStructurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsStructurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19392,16 +18085,12 @@ bool ArrayMultiDimensionLiteralsStructurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsStructurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19410,18 +18099,14 @@ bool ArrayMultiDimensionLiteralsStructurePubSubType::deserialize( ArrayMultiDimensionLiteralsStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -19434,52 +18119,62 @@ bool ArrayMultiDimensionLiteralsStructurePubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsStructurePubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsStructurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsStructurePubSubType::createData() + 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* ArrayMultiDimensionLiteralsStructurePubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsStructure()); } -void ArrayMultiDimensionLiteralsStructurePubSubType::deleteData( +void ArrayMultiDimensionLiteralsStructurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsStructurePubSubType::getKey( +bool ArrayMultiDimensionLiteralsStructurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsStructure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsStructurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -19487,35 +18182,27 @@ bool ArrayMultiDimensionLiteralsStructurePubSubType::getKey( const ArrayMultiDimensionLiteralsStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsStructure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsStructure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -19528,49 +18215,42 @@ void ArrayMultiDimensionLiteralsStructurePubSubType::register_type_object_repres ArrayMultiDimensionLiteralsBitSetPubSubType::ArrayMultiDimensionLiteralsBitSetPubSubType() { - setName("ArrayMultiDimensionLiteralsBitSet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayMultiDimensionLiteralsBitSet::getMaxCdrSerializedSize()); -#else - ArrayMultiDimensionLiteralsBitSet_max_cdr_typesize; -#endif + set_name("ArrayMultiDimensionLiteralsBitSet"); + uint32_t type_size = ArrayMultiDimensionLiteralsBitSet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayMultiDimensionLiteralsBitSet_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsBitSet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayMultiDimensionLiteralsBitSet_max_key_cdr_typesize > 16 ? ArrayMultiDimensionLiteralsBitSet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayMultiDimensionLiteralsBitSetPubSubType::~ArrayMultiDimensionLiteralsBitSetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayMultiDimensionLiteralsBitSetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayMultiDimensionLiteralsBitSet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19585,16 +18265,12 @@ bool ArrayMultiDimensionLiteralsBitSetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayMultiDimensionLiteralsBitSetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19603,18 +18279,14 @@ bool ArrayMultiDimensionLiteralsBitSetPubSubType::deserialize( ArrayMultiDimensionLiteralsBitSet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -19627,52 +18299,62 @@ bool ArrayMultiDimensionLiteralsBitSetPubSubType::deserialize( return true; } -std::function ArrayMultiDimensionLiteralsBitSetPubSubType::getSerializedSizeProvider( +uint32_t ArrayMultiDimensionLiteralsBitSetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ArrayMultiDimensionLiteralsBitSetPubSubType::createData() + 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* ArrayMultiDimensionLiteralsBitSetPubSubType::create_data() { return reinterpret_cast(new ArrayMultiDimensionLiteralsBitSet()); } -void ArrayMultiDimensionLiteralsBitSetPubSubType::deleteData( +void ArrayMultiDimensionLiteralsBitSetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayMultiDimensionLiteralsBitSetPubSubType::getKey( +bool ArrayMultiDimensionLiteralsBitSetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayMultiDimensionLiteralsBitSet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayMultiDimensionLiteralsBitSetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -19680,35 +18362,27 @@ bool ArrayMultiDimensionLiteralsBitSetPubSubType::getKey( const ArrayMultiDimensionLiteralsBitSet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayMultiDimensionLiteralsBitSet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayMultiDimensionLiteralsBitSet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -19721,49 +18395,42 @@ void ArrayMultiDimensionLiteralsBitSetPubSubType::register_type_object_represent BoundedSmallArraysPubSubType::BoundedSmallArraysPubSubType() { - setName("BoundedSmallArrays"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BoundedSmallArrays::getMaxCdrSerializedSize()); -#else - BoundedSmallArrays_max_cdr_typesize; -#endif + set_name("BoundedSmallArrays"); + uint32_t type_size = BoundedSmallArrays_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BoundedSmallArrays_max_key_cdr_typesize > 16 ? BoundedSmallArrays_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BoundedSmallArrays_max_key_cdr_typesize > 16 ? BoundedSmallArrays_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BoundedSmallArraysPubSubType::~BoundedSmallArraysPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BoundedSmallArraysPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BoundedSmallArrays* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19778,16 +18445,12 @@ bool BoundedSmallArraysPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BoundedSmallArraysPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19796,18 +18459,14 @@ bool BoundedSmallArraysPubSubType::deserialize( BoundedSmallArrays* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -19820,52 +18479,62 @@ bool BoundedSmallArraysPubSubType::deserialize( return true; } -std::function BoundedSmallArraysPubSubType::getSerializedSizeProvider( +uint32_t BoundedSmallArraysPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* BoundedSmallArraysPubSubType::createData() + 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* BoundedSmallArraysPubSubType::create_data() { return reinterpret_cast(new BoundedSmallArrays()); } -void BoundedSmallArraysPubSubType::deleteData( +void BoundedSmallArraysPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BoundedSmallArraysPubSubType::getKey( +bool BoundedSmallArraysPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BoundedSmallArrays data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BoundedSmallArraysPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -19873,35 +18542,27 @@ bool BoundedSmallArraysPubSubType::getKey( const BoundedSmallArrays* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BoundedSmallArrays_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BoundedSmallArrays_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -19914,49 +18575,42 @@ void BoundedSmallArraysPubSubType::register_type_object_representation() BoundedBigArraysPubSubType::BoundedBigArraysPubSubType() { - setName("BoundedBigArrays"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BoundedBigArrays::getMaxCdrSerializedSize()); -#else - BoundedBigArrays_max_cdr_typesize; -#endif + set_name("BoundedBigArrays"); + uint32_t type_size = BoundedBigArrays_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BoundedBigArrays_max_key_cdr_typesize > 16 ? BoundedBigArrays_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BoundedBigArrays_max_key_cdr_typesize > 16 ? BoundedBigArrays_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BoundedBigArraysPubSubType::~BoundedBigArraysPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BoundedBigArraysPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BoundedBigArrays* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19971,16 +18625,12 @@ bool BoundedBigArraysPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BoundedBigArraysPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19989,18 +18639,14 @@ bool BoundedBigArraysPubSubType::deserialize( BoundedBigArrays* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -20013,52 +18659,62 @@ bool BoundedBigArraysPubSubType::deserialize( return true; } -std::function BoundedBigArraysPubSubType::getSerializedSizeProvider( +uint32_t BoundedBigArraysPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* BoundedBigArraysPubSubType::createData() + 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* BoundedBigArraysPubSubType::create_data() { return reinterpret_cast(new BoundedBigArrays()); } -void BoundedBigArraysPubSubType::deleteData( +void BoundedBigArraysPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BoundedBigArraysPubSubType::getKey( +bool BoundedBigArraysPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BoundedBigArrays data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BoundedBigArraysPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -20066,35 +18722,27 @@ bool BoundedBigArraysPubSubType::getKey( const BoundedBigArrays* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BoundedBigArrays_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BoundedBigArrays_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/arraysPubSubTypes.hpp b/test/dds-types-test/arraysPubSubTypes.hpp index 5bc03cf83fa..78d92d62170 100644 --- a/test/dds-types-test/arraysPubSubTypes.hpp +++ b/test/dds-types-test/arraysPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated arrays is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class ArrayShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class ArrayShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class ArrayShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class ArrayUShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class ArrayUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class ArrayUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -237,38 +217,30 @@ class ArrayLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -283,10 +255,6 @@ class ArrayLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,8 +275,10 @@ class ArrayLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -328,38 +298,30 @@ class ArrayULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -374,10 +336,6 @@ class ArrayULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -398,8 +356,10 @@ class ArrayULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -419,38 +379,30 @@ class ArrayLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -465,10 +417,6 @@ class ArrayLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -489,8 +437,10 @@ class ArrayLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -510,38 +460,30 @@ class ArrayULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -556,10 +498,6 @@ class ArrayULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -580,8 +518,10 @@ class ArrayULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -601,38 +541,30 @@ class ArrayFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -647,10 +579,6 @@ class ArrayFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -671,8 +599,10 @@ class ArrayFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -692,38 +622,30 @@ class ArrayDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -738,10 +660,6 @@ class ArrayDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -762,8 +680,10 @@ class ArrayDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -783,38 +703,30 @@ class ArrayLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -829,10 +741,6 @@ class ArrayLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -853,8 +761,10 @@ class ArrayLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -874,38 +784,30 @@ class ArrayBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -920,10 +822,6 @@ class ArrayBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -944,8 +842,10 @@ class ArrayBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -965,38 +865,30 @@ class ArrayOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1011,10 +903,6 @@ class ArrayOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1035,8 +923,10 @@ class ArrayOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1056,38 +946,30 @@ class ArrayCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1102,10 +984,6 @@ class ArrayCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1126,8 +1004,10 @@ class ArrayCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1147,38 +1027,30 @@ class ArrayWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1193,10 +1065,6 @@ class ArrayWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1217,8 +1085,10 @@ class ArrayWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1238,38 +1108,30 @@ class ArrayStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1284,10 +1146,6 @@ class ArrayStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1308,8 +1166,10 @@ class ArrayStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1329,38 +1189,30 @@ class ArrayWStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1375,10 +1227,6 @@ class ArrayWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1399,8 +1247,10 @@ class ArrayWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1420,38 +1270,30 @@ class ArrayBoundedStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1466,10 +1308,6 @@ class ArrayBoundedStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1490,8 +1328,10 @@ class ArrayBoundedStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1511,38 +1351,30 @@ class ArrayBoundedWStringPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1557,10 +1389,6 @@ class ArrayBoundedWStringPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1581,8 +1409,10 @@ class ArrayBoundedWStringPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1602,38 +1432,30 @@ class ArrayEnumPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1648,10 +1470,6 @@ class ArrayEnumPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1672,8 +1490,10 @@ class ArrayEnumPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1693,38 +1513,30 @@ class ArrayBitMaskPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1739,10 +1551,6 @@ class ArrayBitMaskPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1763,8 +1571,10 @@ class ArrayBitMaskPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1784,38 +1594,30 @@ class ArrayAliasPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1830,10 +1632,6 @@ class ArrayAliasPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1854,8 +1652,10 @@ class ArrayAliasPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1875,38 +1675,30 @@ class ArrayShortArrayPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1921,10 +1713,6 @@ class ArrayShortArrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1945,8 +1733,10 @@ class ArrayShortArrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1966,38 +1756,30 @@ class ArraySequencePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2012,10 +1794,6 @@ class ArraySequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2036,8 +1814,10 @@ class ArraySequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2057,38 +1837,30 @@ class ArrayMapPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2103,10 +1875,6 @@ class ArrayMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2127,8 +1895,10 @@ class ArrayMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2148,38 +1918,30 @@ class ArrayUnionPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2194,10 +1956,6 @@ class ArrayUnionPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2218,8 +1976,10 @@ class ArrayUnionPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2239,38 +1999,30 @@ class ArrayStructurePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2285,10 +2037,6 @@ class ArrayStructurePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2309,8 +2057,10 @@ class ArrayStructurePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2330,38 +2080,30 @@ class ArrayBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2376,10 +2118,6 @@ class ArrayBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2400,8 +2138,10 @@ class ArrayBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2421,38 +2161,30 @@ class ArrayMultiDimensionShortPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2467,10 +2199,6 @@ class ArrayMultiDimensionShortPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2491,8 +2219,10 @@ class ArrayMultiDimensionShortPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2512,38 +2242,30 @@ class ArrayMultiDimensionUShortPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2558,10 +2280,6 @@ class ArrayMultiDimensionUShortPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2582,8 +2300,10 @@ class ArrayMultiDimensionUShortPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2603,38 +2323,30 @@ class ArrayMultiDimensionLongPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2649,10 +2361,6 @@ class ArrayMultiDimensionLongPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2673,8 +2381,10 @@ class ArrayMultiDimensionLongPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2694,38 +2404,30 @@ class ArrayMultiDimensionULongPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2740,10 +2442,6 @@ class ArrayMultiDimensionULongPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2764,8 +2462,10 @@ class ArrayMultiDimensionULongPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2785,38 +2485,30 @@ class ArrayMultiDimensionLongLongPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2831,10 +2523,6 @@ class ArrayMultiDimensionLongLongPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2855,8 +2543,10 @@ class ArrayMultiDimensionLongLongPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2876,38 +2566,30 @@ class ArrayMultiDimensionULongLongPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2922,10 +2604,6 @@ class ArrayMultiDimensionULongLongPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2946,8 +2624,10 @@ class ArrayMultiDimensionULongLongPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2967,38 +2647,30 @@ class ArrayMultiDimensionFloatPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3013,10 +2685,6 @@ class ArrayMultiDimensionFloatPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3037,8 +2705,10 @@ class ArrayMultiDimensionFloatPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3058,38 +2728,30 @@ class ArrayMultiDimensionDoublePubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3104,10 +2766,6 @@ class ArrayMultiDimensionDoublePubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3128,8 +2786,10 @@ class ArrayMultiDimensionDoublePubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3149,38 +2809,30 @@ class ArrayMultiDimensionLongDoublePubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3195,10 +2847,6 @@ class ArrayMultiDimensionLongDoublePubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3219,8 +2867,10 @@ class ArrayMultiDimensionLongDoublePubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3240,38 +2890,30 @@ class ArrayMultiDimensionBooleanPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3286,10 +2928,6 @@ class ArrayMultiDimensionBooleanPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3310,8 +2948,10 @@ class ArrayMultiDimensionBooleanPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3331,38 +2971,30 @@ class ArrayMultiDimensionOctetPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3377,10 +3009,6 @@ class ArrayMultiDimensionOctetPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3401,8 +3029,10 @@ class ArrayMultiDimensionOctetPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3422,38 +3052,30 @@ class ArrayMultiDimensionCharPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3468,10 +3090,6 @@ class ArrayMultiDimensionCharPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3492,8 +3110,10 @@ class ArrayMultiDimensionCharPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3513,38 +3133,30 @@ class ArrayMultiDimensionWCharPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3559,10 +3171,6 @@ class ArrayMultiDimensionWCharPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3583,8 +3191,10 @@ class ArrayMultiDimensionWCharPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3604,38 +3214,30 @@ class ArrayMultiDimensionStringPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3650,10 +3252,6 @@ class ArrayMultiDimensionStringPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3674,8 +3272,10 @@ class ArrayMultiDimensionStringPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3695,38 +3295,30 @@ class ArrayMultiDimensionWStringPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3741,10 +3333,6 @@ class ArrayMultiDimensionWStringPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3765,8 +3353,10 @@ class ArrayMultiDimensionWStringPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3786,38 +3376,30 @@ class ArrayMultiDimensionBoundedStringPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3832,10 +3414,6 @@ class ArrayMultiDimensionBoundedStringPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3856,8 +3434,10 @@ class ArrayMultiDimensionBoundedStringPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3877,38 +3457,30 @@ class ArrayMultiDimensionBoundedWStringPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3923,10 +3495,6 @@ class ArrayMultiDimensionBoundedWStringPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3947,8 +3515,10 @@ class ArrayMultiDimensionBoundedWStringPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3968,38 +3538,30 @@ class ArrayMultiDimensionEnumPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4014,10 +3576,6 @@ class ArrayMultiDimensionEnumPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4038,8 +3596,10 @@ class ArrayMultiDimensionEnumPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4059,38 +3619,30 @@ class ArrayMultiDimensionBitMaskPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4105,10 +3657,6 @@ class ArrayMultiDimensionBitMaskPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4129,8 +3677,10 @@ class ArrayMultiDimensionBitMaskPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4150,38 +3700,30 @@ class ArrayMultiDimensionAliasPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4196,10 +3738,6 @@ class ArrayMultiDimensionAliasPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4220,8 +3758,10 @@ class ArrayMultiDimensionAliasPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4241,38 +3781,30 @@ class ArrayMultiDimensionSequencePubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4287,10 +3819,6 @@ class ArrayMultiDimensionSequencePubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4311,8 +3839,10 @@ class ArrayMultiDimensionSequencePubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4332,38 +3862,30 @@ class ArrayMultiDimensionMapPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4378,10 +3900,6 @@ class ArrayMultiDimensionMapPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4402,8 +3920,10 @@ class ArrayMultiDimensionMapPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4423,38 +3943,30 @@ class ArrayMultiDimensionUnionPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4469,10 +3981,6 @@ class ArrayMultiDimensionUnionPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4493,8 +4001,10 @@ class ArrayMultiDimensionUnionPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4514,38 +4024,30 @@ class ArrayMultiDimensionStructurePubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4560,10 +4062,6 @@ class ArrayMultiDimensionStructurePubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4584,8 +4082,10 @@ class ArrayMultiDimensionStructurePubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4605,38 +4105,30 @@ class ArrayMultiDimensionBitsetPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4651,10 +4143,6 @@ class ArrayMultiDimensionBitsetPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4675,8 +4163,10 @@ class ArrayMultiDimensionBitsetPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4698,38 +4188,30 @@ class ArraySingleDimensionLiteralsShortPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4744,10 +4226,6 @@ class ArraySingleDimensionLiteralsShortPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4768,8 +4246,10 @@ class ArraySingleDimensionLiteralsShortPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4789,38 +4269,30 @@ class ArraySingleDimensionLiteralsUnsignedShortPubSubType : public eprosima::fas eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4835,10 +4307,6 @@ class ArraySingleDimensionLiteralsUnsignedShortPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4859,8 +4327,10 @@ class ArraySingleDimensionLiteralsUnsignedShortPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4880,38 +4350,30 @@ class ArraySingleDimensionLiteralsLongPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4926,10 +4388,6 @@ class ArraySingleDimensionLiteralsLongPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4950,8 +4408,10 @@ class ArraySingleDimensionLiteralsLongPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4971,38 +4431,30 @@ class ArraySingleDimensionLiteralsUnsignedLongPubSubType : public eprosima::fast eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5017,10 +4469,6 @@ class ArraySingleDimensionLiteralsUnsignedLongPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5041,8 +4489,10 @@ class ArraySingleDimensionLiteralsUnsignedLongPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5062,38 +4512,30 @@ class ArraySingleDimensionLiteralsLongLongPubSubType : public eprosima::fastdds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5108,10 +4550,6 @@ class ArraySingleDimensionLiteralsLongLongPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5132,8 +4570,10 @@ class ArraySingleDimensionLiteralsLongLongPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5153,38 +4593,30 @@ class ArraySingleDimensionLiteralsUnsignedLongLongPubSubType : public eprosima:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5199,10 +4631,6 @@ class ArraySingleDimensionLiteralsUnsignedLongLongPubSubType : public eprosima:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5223,8 +4651,10 @@ class ArraySingleDimensionLiteralsUnsignedLongLongPubSubType : public eprosima:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5244,38 +4674,30 @@ class ArraySingleDimensionLiteralsFloatPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5290,10 +4712,6 @@ class ArraySingleDimensionLiteralsFloatPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5314,8 +4732,10 @@ class ArraySingleDimensionLiteralsFloatPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5335,38 +4755,30 @@ class ArraySingleDimensionLiteralsDoublePubSubType : public eprosima::fastdds::d eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5381,10 +4793,6 @@ class ArraySingleDimensionLiteralsDoublePubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5405,8 +4813,10 @@ class ArraySingleDimensionLiteralsDoublePubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5426,38 +4836,30 @@ class ArraySingleDimensionLiteralsLongDoublePubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5472,10 +4874,6 @@ class ArraySingleDimensionLiteralsLongDoublePubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5496,8 +4894,10 @@ class ArraySingleDimensionLiteralsLongDoublePubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5517,38 +4917,30 @@ class ArraySingleDimensionLiteralsBooleanPubSubType : public eprosima::fastdds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5563,10 +4955,6 @@ class ArraySingleDimensionLiteralsBooleanPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5587,8 +4975,10 @@ class ArraySingleDimensionLiteralsBooleanPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5608,38 +4998,30 @@ class ArraySingleDimensionLiteralsOctetPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5654,10 +5036,6 @@ class ArraySingleDimensionLiteralsOctetPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5678,8 +5056,10 @@ class ArraySingleDimensionLiteralsOctetPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5699,38 +5079,30 @@ class ArraySingleDimensionLiteralsCharPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5745,10 +5117,6 @@ class ArraySingleDimensionLiteralsCharPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5769,8 +5137,10 @@ class ArraySingleDimensionLiteralsCharPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5790,38 +5160,30 @@ class ArraySingleDimensionLiteralsWCharPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5836,10 +5198,6 @@ class ArraySingleDimensionLiteralsWCharPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5860,8 +5218,10 @@ class ArraySingleDimensionLiteralsWCharPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5881,38 +5241,30 @@ class ArraySingleDimensionLiteralsStringPubSubType : public eprosima::fastdds::d eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5927,10 +5279,6 @@ class ArraySingleDimensionLiteralsStringPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5951,8 +5299,10 @@ class ArraySingleDimensionLiteralsStringPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5972,38 +5322,30 @@ class ArraySingleDimensionLiteralsWStringPubSubType : public eprosima::fastdds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6018,10 +5360,6 @@ class ArraySingleDimensionLiteralsWStringPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6042,8 +5380,10 @@ class ArraySingleDimensionLiteralsWStringPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6063,38 +5403,30 @@ class ArraySingleDimensionLiteralsBoundedStringPubSubType : public eprosima::fas eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6109,10 +5441,6 @@ class ArraySingleDimensionLiteralsBoundedStringPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6133,8 +5461,10 @@ class ArraySingleDimensionLiteralsBoundedStringPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6154,38 +5484,30 @@ class ArraySingleDimensionLiteralsBoundedWStringPubSubType : public eprosima::fa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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 std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport bool deserialize( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6200,10 +5522,6 @@ class ArraySingleDimensionLiteralsBoundedWStringPubSubType : public eprosima::fa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6224,8 +5542,10 @@ class ArraySingleDimensionLiteralsBoundedWStringPubSubType : public eprosima::fa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6245,38 +5565,30 @@ class ArraySingleDimensionLiteralsEnumPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6291,10 +5603,6 @@ class ArraySingleDimensionLiteralsEnumPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6315,8 +5623,10 @@ class ArraySingleDimensionLiteralsEnumPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6336,38 +5646,30 @@ class ArraySingleDimensionLiteralsBitMaskPubSubType : public eprosima::fastdds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6382,10 +5684,6 @@ class ArraySingleDimensionLiteralsBitMaskPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6406,8 +5704,10 @@ class ArraySingleDimensionLiteralsBitMaskPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6427,38 +5727,30 @@ class ArraySingleDimensionLiteralsAliasPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6473,10 +5765,6 @@ class ArraySingleDimensionLiteralsAliasPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6497,8 +5785,10 @@ class ArraySingleDimensionLiteralsAliasPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6518,38 +5808,30 @@ class ArraySingleDimensionLiteralsShortArrayPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6564,10 +5846,6 @@ class ArraySingleDimensionLiteralsShortArrayPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6588,8 +5866,10 @@ class ArraySingleDimensionLiteralsShortArrayPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6609,38 +5889,30 @@ class ArraySingleDimensionLiteralsSequencePubSubType : public eprosima::fastdds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6655,10 +5927,6 @@ class ArraySingleDimensionLiteralsSequencePubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6679,8 +5947,10 @@ class ArraySingleDimensionLiteralsSequencePubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6700,38 +5970,30 @@ class ArraySingleDimensionLiteralsMapPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6746,10 +6008,6 @@ class ArraySingleDimensionLiteralsMapPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6770,8 +6028,10 @@ class ArraySingleDimensionLiteralsMapPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6791,38 +6051,30 @@ class ArraySingleDimensionLiteralsUnionPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6837,10 +6089,6 @@ class ArraySingleDimensionLiteralsUnionPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6861,8 +6109,10 @@ class ArraySingleDimensionLiteralsUnionPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6882,38 +6132,30 @@ class ArraySingleDimensionLiteralsStructurePubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6928,10 +6170,6 @@ class ArraySingleDimensionLiteralsStructurePubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6952,8 +6190,10 @@ class ArraySingleDimensionLiteralsStructurePubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6973,38 +6213,30 @@ class ArraySingleDimensionLiteralsBitsetPubSubType : public eprosima::fastdds::d eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7019,10 +6251,6 @@ class ArraySingleDimensionLiteralsBitsetPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7043,8 +6271,10 @@ class ArraySingleDimensionLiteralsBitsetPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7064,38 +6294,30 @@ class ArrayMultiDimensionLiteralsShortPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7110,10 +6332,6 @@ class ArrayMultiDimensionLiteralsShortPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7134,8 +6352,10 @@ class ArrayMultiDimensionLiteralsShortPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7155,38 +6375,30 @@ class ArrayMultiDimensionLiteralsUShortPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7201,10 +6413,6 @@ class ArrayMultiDimensionLiteralsUShortPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7225,8 +6433,10 @@ class ArrayMultiDimensionLiteralsUShortPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7246,38 +6456,30 @@ class ArrayMultiDimensionLiteralsLongPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7292,10 +6494,6 @@ class ArrayMultiDimensionLiteralsLongPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7316,8 +6514,10 @@ class ArrayMultiDimensionLiteralsLongPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7337,38 +6537,30 @@ class ArrayMultiDimensionLiteralsULongPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7383,10 +6575,6 @@ class ArrayMultiDimensionLiteralsULongPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7407,8 +6595,10 @@ class ArrayMultiDimensionLiteralsULongPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7428,38 +6618,30 @@ class ArrayMultiDimensionLiteralsLongLongPubSubType : public eprosima::fastdds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7474,10 +6656,6 @@ class ArrayMultiDimensionLiteralsLongLongPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7498,8 +6676,10 @@ class ArrayMultiDimensionLiteralsLongLongPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7519,38 +6699,30 @@ class ArrayMultiDimensionLiteralsULongLongPubSubType : public eprosima::fastdds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7565,10 +6737,6 @@ class ArrayMultiDimensionLiteralsULongLongPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7589,8 +6757,10 @@ class ArrayMultiDimensionLiteralsULongLongPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7610,38 +6780,30 @@ class ArrayMultiDimensionLiteralsFloatPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7656,10 +6818,6 @@ class ArrayMultiDimensionLiteralsFloatPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7680,8 +6838,10 @@ class ArrayMultiDimensionLiteralsFloatPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7701,38 +6861,30 @@ class ArrayMultiDimensionLiteralsDoublePubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7747,10 +6899,6 @@ class ArrayMultiDimensionLiteralsDoublePubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7771,8 +6919,10 @@ class ArrayMultiDimensionLiteralsDoublePubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7792,38 +6942,30 @@ class ArrayMultiDimensionLiteralsLongDoublePubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7838,10 +6980,6 @@ class ArrayMultiDimensionLiteralsLongDoublePubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7862,8 +7000,10 @@ class ArrayMultiDimensionLiteralsLongDoublePubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7883,38 +7023,30 @@ class ArrayMultiDimensionLiteralsBooleanPubSubType : public eprosima::fastdds::d eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7929,10 +7061,6 @@ class ArrayMultiDimensionLiteralsBooleanPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7953,8 +7081,10 @@ class ArrayMultiDimensionLiteralsBooleanPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7974,38 +7104,30 @@ class ArrayMultiDimensionLiteralsOctetPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8020,10 +7142,6 @@ class ArrayMultiDimensionLiteralsOctetPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8044,8 +7162,10 @@ class ArrayMultiDimensionLiteralsOctetPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8065,38 +7185,30 @@ class ArrayMultiDimensionLiteralsCharPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8111,10 +7223,6 @@ class ArrayMultiDimensionLiteralsCharPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8135,8 +7243,10 @@ class ArrayMultiDimensionLiteralsCharPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8156,38 +7266,30 @@ class ArrayMultiDimensionLiteralsWCharPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8202,10 +7304,6 @@ class ArrayMultiDimensionLiteralsWCharPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8226,8 +7324,10 @@ class ArrayMultiDimensionLiteralsWCharPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8247,38 +7347,30 @@ class ArrayMultiDimensionLiteralsStringPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8293,10 +7385,6 @@ class ArrayMultiDimensionLiteralsStringPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8317,8 +7405,10 @@ class ArrayMultiDimensionLiteralsStringPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8338,38 +7428,30 @@ class ArrayMultiDimensionLiteralsWStringPubSubType : public eprosima::fastdds::d eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8384,10 +7466,6 @@ class ArrayMultiDimensionLiteralsWStringPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8408,8 +7486,10 @@ class ArrayMultiDimensionLiteralsWStringPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8429,38 +7509,30 @@ class ArrayMultiDimensionLiteralsBoundedStringPubSubType : public eprosima::fast eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8475,10 +7547,6 @@ class ArrayMultiDimensionLiteralsBoundedStringPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8499,8 +7567,10 @@ class ArrayMultiDimensionLiteralsBoundedStringPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8520,38 +7590,30 @@ class ArrayMultiDimensionLiteralsBoundedWStringPubSubType : public eprosima::fas eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8566,10 +7628,6 @@ class ArrayMultiDimensionLiteralsBoundedWStringPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8590,8 +7648,10 @@ class ArrayMultiDimensionLiteralsBoundedWStringPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8611,38 +7671,30 @@ class ArrayMultiDimensionLiteralsEnumPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8657,10 +7709,6 @@ class ArrayMultiDimensionLiteralsEnumPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8681,8 +7729,10 @@ class ArrayMultiDimensionLiteralsEnumPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8702,38 +7752,30 @@ class ArrayMultiDimensionLiteralsBitMaskPubSubType : public eprosima::fastdds::d eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8748,10 +7790,6 @@ class ArrayMultiDimensionLiteralsBitMaskPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8772,8 +7810,10 @@ class ArrayMultiDimensionLiteralsBitMaskPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8793,38 +7833,30 @@ class ArrayMultiDimensionLiteralsAliasPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8839,10 +7871,6 @@ class ArrayMultiDimensionLiteralsAliasPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8863,8 +7891,10 @@ class ArrayMultiDimensionLiteralsAliasPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8884,38 +7914,30 @@ class ArrayMultiDimensionLiteralsSequencePubSubType : public eprosima::fastdds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8930,10 +7952,6 @@ class ArrayMultiDimensionLiteralsSequencePubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8954,8 +7972,10 @@ class ArrayMultiDimensionLiteralsSequencePubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8975,38 +7995,30 @@ class ArrayMultiDimensionLiteralsMapPubSubType : public eprosima::fastdds::dds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9021,10 +8033,6 @@ class ArrayMultiDimensionLiteralsMapPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9045,8 +8053,10 @@ class ArrayMultiDimensionLiteralsMapPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9066,38 +8076,30 @@ class ArrayMultiDimensionLiteralsUnionPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9112,10 +8114,6 @@ class ArrayMultiDimensionLiteralsUnionPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9136,8 +8134,10 @@ class ArrayMultiDimensionLiteralsUnionPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9157,38 +8157,30 @@ class ArrayMultiDimensionLiteralsStructurePubSubType : public eprosima::fastdds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9203,10 +8195,6 @@ class ArrayMultiDimensionLiteralsStructurePubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9227,8 +8215,10 @@ class ArrayMultiDimensionLiteralsStructurePubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9248,38 +8238,30 @@ class ArrayMultiDimensionLiteralsBitSetPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9294,10 +8276,6 @@ class ArrayMultiDimensionLiteralsBitSetPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9318,8 +8296,10 @@ class ArrayMultiDimensionLiteralsBitSetPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9339,38 +8319,30 @@ class BoundedSmallArraysPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9385,10 +8357,6 @@ class BoundedSmallArraysPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9409,8 +8377,10 @@ class BoundedSmallArraysPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9430,38 +8400,30 @@ class BoundedBigArraysPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9476,10 +8438,6 @@ class BoundedBigArraysPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9500,8 +8458,10 @@ class BoundedBigArraysPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/bitsetsPubSubTypes.cxx b/test/dds-types-test/bitsetsPubSubTypes.cxx index c5d91cc1dd7..96ea35e4e60 100644 --- a/test/dds-types-test/bitsetsPubSubTypes.cxx +++ b/test/dds-types-test/bitsetsPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; BitsetStructPubSubType::BitsetStructPubSubType() { - setName("BitsetStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BitsetStruct::getMaxCdrSerializedSize()); -#else - BitsetStruct_max_cdr_typesize; -#endif + set_name("BitsetStruct"); + uint32_t type_size = BitsetStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BitsetStruct_max_key_cdr_typesize > 16 ? BitsetStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BitsetStruct_max_key_cdr_typesize > 16 ? BitsetStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BitsetStructPubSubType::~BitsetStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BitsetStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BitsetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool BitsetStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BitsetStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool BitsetStructPubSubType::deserialize( BitsetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool BitsetStructPubSubType::deserialize( return true; } -std::function BitsetStructPubSubType::getSerializedSizeProvider( +uint32_t BitsetStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* BitsetStructPubSubType::createData() +void* BitsetStructPubSubType::create_data() { return reinterpret_cast(new BitsetStruct()); } -void BitsetStructPubSubType::deleteData( +void BitsetStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BitsetStructPubSubType::getKey( +bool BitsetStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BitsetStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BitsetStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool BitsetStructPubSubType::getKey( const BitsetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BitsetStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BitsetStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/bitsetsPubSubTypes.hpp b/test/dds-types-test/bitsetsPubSubTypes.hpp index bb349267a1a..095c73a5fd4 100644 --- a/test/dds-types-test/bitsetsPubSubTypes.hpp +++ b/test/dds-types-test/bitsetsPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated bitsets is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class BitsetStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class BitsetStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class BitsetStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/constantsPubSubTypes.cxx b/test/dds-types-test/constantsPubSubTypes.cxx index 6ef0459d6e6..94a0e0429fe 100644 --- a/test/dds-types-test/constantsPubSubTypes.cxx +++ b/test/dds-types-test/constantsPubSubTypes.cxx @@ -34,49 +34,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; namespace const_module1 { ModuleConstsLiteralsStructPubSubType::ModuleConstsLiteralsStructPubSubType() { - setName("const_module1::ModuleConstsLiteralsStruct"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(ModuleConstsLiteralsStruct::getMaxCdrSerializedSize()); - #else - const_module1_ModuleConstsLiteralsStruct_max_cdr_typesize; - #endif + set_name("const_module1::ModuleConstsLiteralsStruct"); + uint32_t type_size = const_module1_ModuleConstsLiteralsStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = const_module1_ModuleConstsLiteralsStruct_max_key_cdr_typesize > 16 ? const_module1_ModuleConstsLiteralsStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = const_module1_ModuleConstsLiteralsStruct_max_key_cdr_typesize > 16 ? const_module1_ModuleConstsLiteralsStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ModuleConstsLiteralsStructPubSubType::~ModuleConstsLiteralsStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ModuleConstsLiteralsStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ModuleConstsLiteralsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -91,16 +84,12 @@ namespace const_module1 { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ModuleConstsLiteralsStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -109,18 +98,14 @@ namespace const_module1 { ModuleConstsLiteralsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -133,52 +118,62 @@ namespace const_module1 { return true; } - std::function ModuleConstsLiteralsStructPubSubType::getSerializedSizeProvider( + uint32_t ModuleConstsLiteralsStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* ModuleConstsLiteralsStructPubSubType::createData() + 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* ModuleConstsLiteralsStructPubSubType::create_data() { return reinterpret_cast(new ModuleConstsLiteralsStruct()); } - void ModuleConstsLiteralsStructPubSubType::deleteData( + void ModuleConstsLiteralsStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool ModuleConstsLiteralsStructPubSubType::getKey( + bool ModuleConstsLiteralsStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + ModuleConstsLiteralsStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool ModuleConstsLiteralsStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -186,35 +181,27 @@ namespace const_module1 { const ModuleConstsLiteralsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), const_module1_ModuleConstsLiteralsStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || const_module1_ModuleConstsLiteralsStruct_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -230,49 +217,42 @@ namespace const_module1 { namespace const_module2 { Module2ConstsLiteralsStructPubSubType::Module2ConstsLiteralsStructPubSubType() { - setName("const_module2::Module2ConstsLiteralsStruct"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(Module2ConstsLiteralsStruct::getMaxCdrSerializedSize()); - #else - const_module2_Module2ConstsLiteralsStruct_max_cdr_typesize; - #endif + set_name("const_module2::Module2ConstsLiteralsStruct"); + uint32_t type_size = const_module2_Module2ConstsLiteralsStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = const_module2_Module2ConstsLiteralsStruct_max_key_cdr_typesize > 16 ? const_module2_Module2ConstsLiteralsStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = const_module2_Module2ConstsLiteralsStruct_max_key_cdr_typesize > 16 ? const_module2_Module2ConstsLiteralsStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Module2ConstsLiteralsStructPubSubType::~Module2ConstsLiteralsStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Module2ConstsLiteralsStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Module2ConstsLiteralsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -287,16 +267,12 @@ namespace const_module2 { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Module2ConstsLiteralsStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -305,18 +281,14 @@ namespace const_module2 { Module2ConstsLiteralsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -329,52 +301,62 @@ namespace const_module2 { return true; } - std::function Module2ConstsLiteralsStructPubSubType::getSerializedSizeProvider( + uint32_t Module2ConstsLiteralsStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* Module2ConstsLiteralsStructPubSubType::createData() + 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* Module2ConstsLiteralsStructPubSubType::create_data() { return reinterpret_cast(new Module2ConstsLiteralsStruct()); } - void Module2ConstsLiteralsStructPubSubType::deleteData( + void Module2ConstsLiteralsStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool Module2ConstsLiteralsStructPubSubType::getKey( + bool Module2ConstsLiteralsStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + Module2ConstsLiteralsStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool Module2ConstsLiteralsStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -382,35 +364,27 @@ namespace const_module2 { const Module2ConstsLiteralsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), const_module2_Module2ConstsLiteralsStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || const_module2_Module2ConstsLiteralsStruct_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -425,49 +399,42 @@ namespace const_module2 { ConstsLiteralsStructPubSubType::ConstsLiteralsStructPubSubType() { - setName("ConstsLiteralsStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ConstsLiteralsStruct::getMaxCdrSerializedSize()); -#else - ConstsLiteralsStruct_max_cdr_typesize; -#endif + set_name("ConstsLiteralsStruct"); + uint32_t type_size = ConstsLiteralsStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ConstsLiteralsStruct_max_key_cdr_typesize > 16 ? ConstsLiteralsStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ConstsLiteralsStruct_max_key_cdr_typesize > 16 ? ConstsLiteralsStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ConstsLiteralsStructPubSubType::~ConstsLiteralsStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ConstsLiteralsStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ConstsLiteralsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -482,16 +449,12 @@ bool ConstsLiteralsStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ConstsLiteralsStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -500,18 +463,14 @@ bool ConstsLiteralsStructPubSubType::deserialize( ConstsLiteralsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -524,52 +483,62 @@ bool ConstsLiteralsStructPubSubType::deserialize( return true; } -std::function ConstsLiteralsStructPubSubType::getSerializedSizeProvider( +uint32_t ConstsLiteralsStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ConstsLiteralsStructPubSubType::createData() +void* ConstsLiteralsStructPubSubType::create_data() { return reinterpret_cast(new ConstsLiteralsStruct()); } -void ConstsLiteralsStructPubSubType::deleteData( +void ConstsLiteralsStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ConstsLiteralsStructPubSubType::getKey( +bool ConstsLiteralsStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ConstsLiteralsStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ConstsLiteralsStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -577,35 +546,27 @@ bool ConstsLiteralsStructPubSubType::getKey( const ConstsLiteralsStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ConstsLiteralsStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ConstsLiteralsStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/constantsPubSubTypes.hpp b/test/dds-types-test/constantsPubSubTypes.hpp index e756388d7d5..f220b1da26f 100644 --- a/test/dds-types-test/constantsPubSubTypes.hpp +++ b/test/dds-types-test/constantsPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated constants is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER typedef int16_t alias_short; @@ -61,38 +61,30 @@ namespace const_module1 eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -107,10 +99,6 @@ namespace const_module1 #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -131,8 +119,10 @@ namespace const_module1 #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace const_module1 @@ -155,38 +145,30 @@ namespace const_module2 eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -201,10 +183,6 @@ namespace const_module2 #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -225,8 +203,10 @@ namespace const_module2 #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace const_module2 @@ -247,38 +227,30 @@ class ConstsLiteralsStructPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -293,10 +265,6 @@ class ConstsLiteralsStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -317,8 +285,10 @@ class ConstsLiteralsStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/declarationsPubSubTypes.cxx b/test/dds-types-test/declarationsPubSubTypes.cxx index 6c060c36f7d..80ddc224b57 100644 --- a/test/dds-types-test/declarationsPubSubTypes.cxx +++ b/test/dds-types-test/declarationsPubSubTypes.cxx @@ -31,49 +31,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; ForwardDeclarationsRecursiveStructPubSubType::ForwardDeclarationsRecursiveStructPubSubType() { - setName("ForwardDeclarationsRecursiveStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ForwardDeclarationsRecursiveStruct::getMaxCdrSerializedSize()); -#else - ForwardDeclarationsRecursiveStruct_max_cdr_typesize; -#endif + set_name("ForwardDeclarationsRecursiveStruct"); + uint32_t type_size = ForwardDeclarationsRecursiveStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ForwardDeclarationsRecursiveStruct_max_key_cdr_typesize > 16 ? ForwardDeclarationsRecursiveStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ForwardDeclarationsRecursiveStruct_max_key_cdr_typesize > 16 ? ForwardDeclarationsRecursiveStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ForwardDeclarationsRecursiveStructPubSubType::~ForwardDeclarationsRecursiveStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ForwardDeclarationsRecursiveStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ForwardDeclarationsRecursiveStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -88,16 +81,12 @@ bool ForwardDeclarationsRecursiveStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ForwardDeclarationsRecursiveStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -106,18 +95,14 @@ bool ForwardDeclarationsRecursiveStructPubSubType::deserialize( ForwardDeclarationsRecursiveStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -130,52 +115,62 @@ bool ForwardDeclarationsRecursiveStructPubSubType::deserialize( return true; } -std::function ForwardDeclarationsRecursiveStructPubSubType::getSerializedSizeProvider( +uint32_t ForwardDeclarationsRecursiveStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ForwardDeclarationsRecursiveStructPubSubType::createData() +void* ForwardDeclarationsRecursiveStructPubSubType::create_data() { return reinterpret_cast(new ForwardDeclarationsRecursiveStruct()); } -void ForwardDeclarationsRecursiveStructPubSubType::deleteData( +void ForwardDeclarationsRecursiveStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ForwardDeclarationsRecursiveStructPubSubType::getKey( +bool ForwardDeclarationsRecursiveStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ForwardDeclarationsRecursiveStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ForwardDeclarationsRecursiveStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -183,35 +178,27 @@ bool ForwardDeclarationsRecursiveStructPubSubType::getKey( const ForwardDeclarationsRecursiveStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ForwardDeclarationsRecursiveStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ForwardDeclarationsRecursiveStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void ForwardDeclarationsRecursiveStructPubSubType::register_type_object_represen ForwardStructPubSubType::ForwardStructPubSubType() { - setName("ForwardStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ForwardStruct::getMaxCdrSerializedSize()); -#else - ForwardStruct_max_cdr_typesize; -#endif + set_name("ForwardStruct"); + uint32_t type_size = ForwardStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ForwardStruct_max_key_cdr_typesize > 16 ? ForwardStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ForwardStruct_max_key_cdr_typesize > 16 ? ForwardStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ForwardStructPubSubType::~ForwardStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ForwardStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ForwardStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool ForwardStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ForwardStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool ForwardStructPubSubType::deserialize( ForwardStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool ForwardStructPubSubType::deserialize( return true; } -std::function ForwardStructPubSubType::getSerializedSizeProvider( +uint32_t ForwardStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ForwardStructPubSubType::createData() +void* ForwardStructPubSubType::create_data() { return reinterpret_cast(new ForwardStruct()); } -void ForwardStructPubSubType::deleteData( +void ForwardStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ForwardStructPubSubType::getKey( +bool ForwardStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ForwardStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ForwardStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool ForwardStructPubSubType::getKey( const ForwardStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ForwardStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ForwardStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -421,49 +395,42 @@ void ForwardStructPubSubType::register_type_object_representation() namespace declarations_module { ForwardStructPubSubType::ForwardStructPubSubType() { - setName("declarations_module::ForwardStruct"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(ForwardStruct::getMaxCdrSerializedSize()); - #else - declarations_module_ForwardStruct_max_cdr_typesize; - #endif + set_name("declarations_module::ForwardStruct"); + uint32_t type_size = declarations_module_ForwardStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = declarations_module_ForwardStruct_max_key_cdr_typesize > 16 ? declarations_module_ForwardStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = declarations_module_ForwardStruct_max_key_cdr_typesize > 16 ? declarations_module_ForwardStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ForwardStructPubSubType::~ForwardStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ForwardStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ForwardStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -478,16 +445,12 @@ namespace declarations_module { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ForwardStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -496,18 +459,14 @@ namespace declarations_module { ForwardStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -520,52 +479,62 @@ namespace declarations_module { return true; } - std::function ForwardStructPubSubType::getSerializedSizeProvider( + uint32_t ForwardStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* ForwardStructPubSubType::createData() + 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* ForwardStructPubSubType::create_data() { return reinterpret_cast(new ForwardStruct()); } - void ForwardStructPubSubType::deleteData( + void ForwardStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool ForwardStructPubSubType::getKey( + bool ForwardStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + ForwardStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool ForwardStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -573,35 +542,27 @@ namespace declarations_module { const ForwardStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), declarations_module_ForwardStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || declarations_module_ForwardStruct_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -617,49 +578,42 @@ namespace declarations_module { ModuledForwardDeclarationsRecursiveStructPubSubType::ModuledForwardDeclarationsRecursiveStructPubSubType() { - setName("ModuledForwardDeclarationsRecursiveStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ModuledForwardDeclarationsRecursiveStruct::getMaxCdrSerializedSize()); -#else - ModuledForwardDeclarationsRecursiveStruct_max_cdr_typesize; -#endif + set_name("ModuledForwardDeclarationsRecursiveStruct"); + uint32_t type_size = ModuledForwardDeclarationsRecursiveStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ModuledForwardDeclarationsRecursiveStruct_max_key_cdr_typesize > 16 ? ModuledForwardDeclarationsRecursiveStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ModuledForwardDeclarationsRecursiveStruct_max_key_cdr_typesize > 16 ? ModuledForwardDeclarationsRecursiveStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ModuledForwardDeclarationsRecursiveStructPubSubType::~ModuledForwardDeclarationsRecursiveStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ModuledForwardDeclarationsRecursiveStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ModuledForwardDeclarationsRecursiveStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -674,16 +628,12 @@ bool ModuledForwardDeclarationsRecursiveStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ModuledForwardDeclarationsRecursiveStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -692,18 +642,14 @@ bool ModuledForwardDeclarationsRecursiveStructPubSubType::deserialize( ModuledForwardDeclarationsRecursiveStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -716,52 +662,62 @@ bool ModuledForwardDeclarationsRecursiveStructPubSubType::deserialize( return true; } -std::function ModuledForwardDeclarationsRecursiveStructPubSubType::getSerializedSizeProvider( +uint32_t ModuledForwardDeclarationsRecursiveStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ModuledForwardDeclarationsRecursiveStructPubSubType::createData() +void* ModuledForwardDeclarationsRecursiveStructPubSubType::create_data() { return reinterpret_cast(new ModuledForwardDeclarationsRecursiveStruct()); } -void ModuledForwardDeclarationsRecursiveStructPubSubType::deleteData( +void ModuledForwardDeclarationsRecursiveStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ModuledForwardDeclarationsRecursiveStructPubSubType::getKey( +bool ModuledForwardDeclarationsRecursiveStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ModuledForwardDeclarationsRecursiveStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ModuledForwardDeclarationsRecursiveStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -769,35 +725,27 @@ bool ModuledForwardDeclarationsRecursiveStructPubSubType::getKey( const ModuledForwardDeclarationsRecursiveStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ModuledForwardDeclarationsRecursiveStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ModuledForwardDeclarationsRecursiveStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -812,49 +760,42 @@ void ModuledForwardDeclarationsRecursiveStructPubSubType::register_type_object_r namespace declarations_module { ModuledForwardStructPubSubType::ModuledForwardStructPubSubType() { - setName("declarations_module::ModuledForwardStruct"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(ModuledForwardStruct::getMaxCdrSerializedSize()); - #else - declarations_module_ModuledForwardStruct_max_cdr_typesize; - #endif + set_name("declarations_module::ModuledForwardStruct"); + uint32_t type_size = declarations_module_ModuledForwardStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = declarations_module_ModuledForwardStruct_max_key_cdr_typesize > 16 ? declarations_module_ModuledForwardStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = declarations_module_ModuledForwardStruct_max_key_cdr_typesize > 16 ? declarations_module_ModuledForwardStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ModuledForwardStructPubSubType::~ModuledForwardStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ModuledForwardStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ModuledForwardStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -869,16 +810,12 @@ namespace declarations_module { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ModuledForwardStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -887,18 +824,14 @@ namespace declarations_module { ModuledForwardStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -911,52 +844,62 @@ namespace declarations_module { return true; } - std::function ModuledForwardStructPubSubType::getSerializedSizeProvider( + uint32_t ModuledForwardStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* ModuledForwardStructPubSubType::createData() + 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* ModuledForwardStructPubSubType::create_data() { return reinterpret_cast(new ModuledForwardStruct()); } - void ModuledForwardStructPubSubType::deleteData( + void ModuledForwardStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool ModuledForwardStructPubSubType::getKey( + bool ModuledForwardStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + ModuledForwardStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool ModuledForwardStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -964,35 +907,27 @@ namespace declarations_module { const ModuledForwardStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), declarations_module_ModuledForwardStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || declarations_module_ModuledForwardStruct_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1010,49 +945,42 @@ namespace declarations_module { ModuledCommonNameStructurePubSubType::ModuledCommonNameStructurePubSubType() { - setName("ModuledCommonNameStructure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ModuledCommonNameStructure::getMaxCdrSerializedSize()); -#else - ModuledCommonNameStructure_max_cdr_typesize; -#endif + set_name("ModuledCommonNameStructure"); + uint32_t type_size = ModuledCommonNameStructure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ModuledCommonNameStructure_max_key_cdr_typesize > 16 ? ModuledCommonNameStructure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ModuledCommonNameStructure_max_key_cdr_typesize > 16 ? ModuledCommonNameStructure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ModuledCommonNameStructurePubSubType::~ModuledCommonNameStructurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ModuledCommonNameStructurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ModuledCommonNameStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1067,16 +995,12 @@ bool ModuledCommonNameStructurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ModuledCommonNameStructurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1085,18 +1009,14 @@ bool ModuledCommonNameStructurePubSubType::deserialize( ModuledCommonNameStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1109,52 +1029,62 @@ bool ModuledCommonNameStructurePubSubType::deserialize( return true; } -std::function ModuledCommonNameStructurePubSubType::getSerializedSizeProvider( +uint32_t ModuledCommonNameStructurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ModuledCommonNameStructurePubSubType::createData() +void* ModuledCommonNameStructurePubSubType::create_data() { return reinterpret_cast(new ModuledCommonNameStructure()); } -void ModuledCommonNameStructurePubSubType::deleteData( +void ModuledCommonNameStructurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ModuledCommonNameStructurePubSubType::getKey( +bool ModuledCommonNameStructurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ModuledCommonNameStructure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ModuledCommonNameStructurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1162,35 +1092,27 @@ bool ModuledCommonNameStructurePubSubType::getKey( const ModuledCommonNameStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ModuledCommonNameStructure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ModuledCommonNameStructure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/declarationsPubSubTypes.hpp b/test/dds-types-test/declarationsPubSubTypes.hpp index d066074f218..a3e57c0bc1b 100644 --- a/test/dds-types-test/declarationsPubSubTypes.hpp +++ b/test/dds-types-test/declarationsPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "declarations.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated declarations is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER typedef std::vector RecursiveUnboundedSeqForwardStruct; typedef std::vector RecursiveBoundedSeqForwardStruct; @@ -59,38 +59,30 @@ class ForwardDeclarationsRecursiveStructPubSubType : public eprosima::fastdds::d eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -105,10 +97,6 @@ class ForwardDeclarationsRecursiveStructPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -129,8 +117,10 @@ class ForwardDeclarationsRecursiveStructPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -151,38 +141,30 @@ class ForwardStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -197,10 +179,6 @@ class ForwardStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -221,8 +199,10 @@ class ForwardStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; namespace declarations_module @@ -248,38 +228,30 @@ namespace declarations_module eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -294,10 +266,6 @@ namespace declarations_module #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -318,8 +286,10 @@ namespace declarations_module #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace declarations_module @@ -340,38 +310,30 @@ class ModuledForwardDeclarationsRecursiveStructPubSubType : public eprosima::fas eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -386,10 +348,6 @@ class ModuledForwardDeclarationsRecursiveStructPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -410,8 +368,10 @@ class ModuledForwardDeclarationsRecursiveStructPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; namespace declarations_module @@ -433,38 +393,30 @@ namespace declarations_module eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -479,10 +431,6 @@ namespace declarations_module #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -503,8 +451,10 @@ namespace declarations_module #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -527,38 +477,30 @@ class ModuledCommonNameStructurePubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -573,10 +515,6 @@ class ModuledCommonNameStructurePubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -597,8 +535,10 @@ class ModuledCommonNameStructurePubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/enumerationsPubSubTypes.cxx b/test/dds-types-test/enumerationsPubSubTypes.cxx index 3ce6ab2b8ce..9793e3907ad 100644 --- a/test/dds-types-test/enumerationsPubSubTypes.cxx +++ b/test/dds-types-test/enumerationsPubSubTypes.cxx @@ -36,49 +36,42 @@ namespace Test { EnumStructurePubSubType::EnumStructurePubSubType() { - setName("EnumStructure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(EnumStructure::getMaxCdrSerializedSize()); -#else - EnumStructure_max_cdr_typesize; -#endif + set_name("EnumStructure"); + uint32_t type_size = EnumStructure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = EnumStructure_max_key_cdr_typesize > 16 ? EnumStructure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = EnumStructure_max_key_cdr_typesize > 16 ? EnumStructure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EnumStructurePubSubType::~EnumStructurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EnumStructurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EnumStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -93,16 +86,12 @@ bool EnumStructurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EnumStructurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -111,18 +100,14 @@ bool EnumStructurePubSubType::deserialize( EnumStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -135,52 +120,62 @@ bool EnumStructurePubSubType::deserialize( return true; } -std::function EnumStructurePubSubType::getSerializedSizeProvider( +uint32_t EnumStructurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* EnumStructurePubSubType::createData() +void* EnumStructurePubSubType::create_data() { return reinterpret_cast(new EnumStructure()); } -void EnumStructurePubSubType::deleteData( +void EnumStructurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool EnumStructurePubSubType::getKey( +bool EnumStructurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + EnumStructure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool EnumStructurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -188,35 +183,27 @@ bool EnumStructurePubSubType::getKey( const EnumStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), EnumStructure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || EnumStructure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -229,49 +216,42 @@ void EnumStructurePubSubType::register_type_object_representation() BitMaskStructurePubSubType::BitMaskStructurePubSubType() { - setName("BitMaskStructure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BitMaskStructure::getMaxCdrSerializedSize()); -#else - BitMaskStructure_max_cdr_typesize; -#endif + set_name("BitMaskStructure"); + uint32_t type_size = BitMaskStructure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BitMaskStructure_max_key_cdr_typesize > 16 ? BitMaskStructure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BitMaskStructure_max_key_cdr_typesize > 16 ? BitMaskStructure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BitMaskStructurePubSubType::~BitMaskStructurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BitMaskStructurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BitMaskStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -286,16 +266,12 @@ bool BitMaskStructurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BitMaskStructurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -304,18 +280,14 @@ bool BitMaskStructurePubSubType::deserialize( BitMaskStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -328,52 +300,62 @@ bool BitMaskStructurePubSubType::deserialize( return true; } -std::function BitMaskStructurePubSubType::getSerializedSizeProvider( +uint32_t BitMaskStructurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* BitMaskStructurePubSubType::createData() +void* BitMaskStructurePubSubType::create_data() { return reinterpret_cast(new BitMaskStructure()); } -void BitMaskStructurePubSubType::deleteData( +void BitMaskStructurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BitMaskStructurePubSubType::getKey( +bool BitMaskStructurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BitMaskStructure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BitMaskStructurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -381,35 +363,27 @@ bool BitMaskStructurePubSubType::getKey( const BitMaskStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BitMaskStructure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BitMaskStructure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -422,49 +396,42 @@ void BitMaskStructurePubSubType::register_type_object_representation() BoundedBitMaskStructurePubSubType::BoundedBitMaskStructurePubSubType() { - setName("BoundedBitMaskStructure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BoundedBitMaskStructure::getMaxCdrSerializedSize()); -#else - BoundedBitMaskStructure_max_cdr_typesize; -#endif + set_name("BoundedBitMaskStructure"); + uint32_t type_size = BoundedBitMaskStructure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BoundedBitMaskStructure_max_key_cdr_typesize > 16 ? BoundedBitMaskStructure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BoundedBitMaskStructure_max_key_cdr_typesize > 16 ? BoundedBitMaskStructure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BoundedBitMaskStructurePubSubType::~BoundedBitMaskStructurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BoundedBitMaskStructurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BoundedBitMaskStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -479,16 +446,12 @@ bool BoundedBitMaskStructurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BoundedBitMaskStructurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -497,18 +460,14 @@ bool BoundedBitMaskStructurePubSubType::deserialize( BoundedBitMaskStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -521,52 +480,62 @@ bool BoundedBitMaskStructurePubSubType::deserialize( return true; } -std::function BoundedBitMaskStructurePubSubType::getSerializedSizeProvider( +uint32_t BoundedBitMaskStructurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* BoundedBitMaskStructurePubSubType::createData() +void* BoundedBitMaskStructurePubSubType::create_data() { return reinterpret_cast(new BoundedBitMaskStructure()); } -void BoundedBitMaskStructurePubSubType::deleteData( +void BoundedBitMaskStructurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BoundedBitMaskStructurePubSubType::getKey( +bool BoundedBitMaskStructurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BoundedBitMaskStructure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BoundedBitMaskStructurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -574,35 +543,27 @@ bool BoundedBitMaskStructurePubSubType::getKey( const BoundedBitMaskStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BoundedBitMaskStructure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BoundedBitMaskStructure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/enumerationsPubSubTypes.hpp b/test/dds-types-test/enumerationsPubSubTypes.hpp index f2ac0587742..bd437018d10 100644 --- a/test/dds-types-test/enumerationsPubSubTypes.hpp +++ b/test/dds-types-test/enumerationsPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated enumerations is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER namespace Test { @@ -58,38 +58,30 @@ class EnumStructurePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -104,10 +96,6 @@ class EnumStructurePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -128,8 +116,10 @@ class EnumStructurePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -149,38 +139,30 @@ class BitMaskStructurePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -195,10 +177,6 @@ class BitMaskStructurePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -219,8 +197,10 @@ class BitMaskStructurePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -240,38 +220,30 @@ class BoundedBitMaskStructurePubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -286,10 +258,6 @@ class BoundedBitMaskStructurePubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -310,8 +278,10 @@ class BoundedBitMaskStructurePubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/externalPubSubTypes.cxx b/test/dds-types-test/externalPubSubTypes.cxx index 2c136fe9f45..9f2241b0b68 100644 --- a/test/dds-types-test/externalPubSubTypes.cxx +++ b/test/dds-types-test/externalPubSubTypes.cxx @@ -31,49 +31,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; short_externalPubSubType::short_externalPubSubType() { - setName("short_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(short_external::getMaxCdrSerializedSize()); -#else - short_external_max_cdr_typesize; -#endif + set_name("short_external"); + uint32_t type_size = short_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = short_external_max_key_cdr_typesize > 16 ? short_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = short_external_max_key_cdr_typesize > 16 ? short_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } short_externalPubSubType::~short_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool short_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -88,16 +81,12 @@ bool short_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool short_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -106,18 +95,14 @@ bool short_externalPubSubType::deserialize( short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -130,52 +115,62 @@ bool short_externalPubSubType::deserialize( return true; } -std::function short_externalPubSubType::getSerializedSizeProvider( +uint32_t short_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* short_externalPubSubType::createData() + 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* short_externalPubSubType::create_data() { return reinterpret_cast(new short_external()); } -void short_externalPubSubType::deleteData( +void short_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool short_externalPubSubType::getKey( +bool short_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + short_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool short_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -183,35 +178,27 @@ bool short_externalPubSubType::getKey( const short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), short_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || short_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -225,49 +212,42 @@ void short_externalPubSubType::register_type_object_representation() ushort_externalPubSubType::ushort_externalPubSubType() { - setName("ushort_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ushort_external::getMaxCdrSerializedSize()); -#else - ushort_external_max_cdr_typesize; -#endif + set_name("ushort_external"); + uint32_t type_size = ushort_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ushort_external_max_key_cdr_typesize > 16 ? ushort_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ushort_external_max_key_cdr_typesize > 16 ? ushort_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ushort_externalPubSubType::~ushort_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ushort_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ushort_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -282,16 +262,12 @@ bool ushort_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ushort_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -300,18 +276,14 @@ bool ushort_externalPubSubType::deserialize( ushort_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -324,52 +296,62 @@ bool ushort_externalPubSubType::deserialize( return true; } -std::function ushort_externalPubSubType::getSerializedSizeProvider( +uint32_t ushort_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ushort_externalPubSubType::createData() + 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* ushort_externalPubSubType::create_data() { return reinterpret_cast(new ushort_external()); } -void ushort_externalPubSubType::deleteData( +void ushort_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ushort_externalPubSubType::getKey( +bool ushort_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ushort_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ushort_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -377,35 +359,27 @@ bool ushort_externalPubSubType::getKey( const ushort_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ushort_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ushort_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void ushort_externalPubSubType::register_type_object_representation() long_externalPubSubType::long_externalPubSubType() { - setName("long_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(long_external::getMaxCdrSerializedSize()); -#else - long_external_max_cdr_typesize; -#endif + set_name("long_external"); + uint32_t type_size = long_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = long_external_max_key_cdr_typesize > 16 ? long_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = long_external_max_key_cdr_typesize > 16 ? long_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } long_externalPubSubType::~long_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool long_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const long_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool long_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool long_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool long_externalPubSubType::deserialize( long_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool long_externalPubSubType::deserialize( return true; } -std::function long_externalPubSubType::getSerializedSizeProvider( +uint32_t long_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* long_externalPubSubType::createData() + 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* long_externalPubSubType::create_data() { return reinterpret_cast(new long_external()); } -void long_externalPubSubType::deleteData( +void long_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool long_externalPubSubType::getKey( +bool long_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + long_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool long_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool long_externalPubSubType::getKey( const long_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), long_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || long_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -613,49 +574,42 @@ void long_externalPubSubType::register_type_object_representation() ulong_externalPubSubType::ulong_externalPubSubType() { - setName("ulong_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ulong_external::getMaxCdrSerializedSize()); -#else - ulong_external_max_cdr_typesize; -#endif + set_name("ulong_external"); + uint32_t type_size = ulong_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ulong_external_max_key_cdr_typesize > 16 ? ulong_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ulong_external_max_key_cdr_typesize > 16 ? ulong_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ulong_externalPubSubType::~ulong_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ulong_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ulong_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -670,16 +624,12 @@ bool ulong_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ulong_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -688,18 +638,14 @@ bool ulong_externalPubSubType::deserialize( ulong_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -712,52 +658,62 @@ bool ulong_externalPubSubType::deserialize( return true; } -std::function ulong_externalPubSubType::getSerializedSizeProvider( +uint32_t ulong_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ulong_externalPubSubType::createData() + 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* ulong_externalPubSubType::create_data() { return reinterpret_cast(new ulong_external()); } -void ulong_externalPubSubType::deleteData( +void ulong_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ulong_externalPubSubType::getKey( +bool ulong_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ulong_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ulong_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -765,35 +721,27 @@ bool ulong_externalPubSubType::getKey( const ulong_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ulong_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ulong_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -807,49 +755,42 @@ void ulong_externalPubSubType::register_type_object_representation() longlong_externalPubSubType::longlong_externalPubSubType() { - setName("longlong_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(longlong_external::getMaxCdrSerializedSize()); -#else - longlong_external_max_cdr_typesize; -#endif + set_name("longlong_external"); + uint32_t type_size = longlong_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = longlong_external_max_key_cdr_typesize > 16 ? longlong_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = longlong_external_max_key_cdr_typesize > 16 ? longlong_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } longlong_externalPubSubType::~longlong_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool longlong_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const longlong_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -864,16 +805,12 @@ bool longlong_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool longlong_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -882,18 +819,14 @@ bool longlong_externalPubSubType::deserialize( longlong_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -906,52 +839,62 @@ bool longlong_externalPubSubType::deserialize( return true; } -std::function longlong_externalPubSubType::getSerializedSizeProvider( +uint32_t longlong_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* longlong_externalPubSubType::createData() + 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* longlong_externalPubSubType::create_data() { return reinterpret_cast(new longlong_external()); } -void longlong_externalPubSubType::deleteData( +void longlong_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool longlong_externalPubSubType::getKey( +bool longlong_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + longlong_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool longlong_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -959,35 +902,27 @@ bool longlong_externalPubSubType::getKey( const longlong_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), longlong_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || longlong_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1001,49 +936,42 @@ void longlong_externalPubSubType::register_type_object_representation() ulonglong_externalPubSubType::ulonglong_externalPubSubType() { - setName("ulonglong_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ulonglong_external::getMaxCdrSerializedSize()); -#else - ulonglong_external_max_cdr_typesize; -#endif + set_name("ulonglong_external"); + uint32_t type_size = ulonglong_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ulonglong_external_max_key_cdr_typesize > 16 ? ulonglong_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ulonglong_external_max_key_cdr_typesize > 16 ? ulonglong_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ulonglong_externalPubSubType::~ulonglong_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ulonglong_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ulonglong_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1058,16 +986,12 @@ bool ulonglong_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ulonglong_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1076,18 +1000,14 @@ bool ulonglong_externalPubSubType::deserialize( ulonglong_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1100,52 +1020,62 @@ bool ulonglong_externalPubSubType::deserialize( return true; } -std::function ulonglong_externalPubSubType::getSerializedSizeProvider( +uint32_t ulonglong_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ulonglong_externalPubSubType::createData() + 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* ulonglong_externalPubSubType::create_data() { return reinterpret_cast(new ulonglong_external()); } -void ulonglong_externalPubSubType::deleteData( +void ulonglong_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ulonglong_externalPubSubType::getKey( +bool ulonglong_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ulonglong_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ulonglong_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1153,35 +1083,27 @@ bool ulonglong_externalPubSubType::getKey( const ulonglong_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ulonglong_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ulonglong_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1195,49 +1117,42 @@ void ulonglong_externalPubSubType::register_type_object_representation() float_externalPubSubType::float_externalPubSubType() { - setName("float_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(float_external::getMaxCdrSerializedSize()); -#else - float_external_max_cdr_typesize; -#endif + set_name("float_external"); + uint32_t type_size = float_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = float_external_max_key_cdr_typesize > 16 ? float_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = float_external_max_key_cdr_typesize > 16 ? float_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } float_externalPubSubType::~float_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool float_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const float_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1252,16 +1167,12 @@ bool float_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool float_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1270,18 +1181,14 @@ bool float_externalPubSubType::deserialize( float_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1294,52 +1201,62 @@ bool float_externalPubSubType::deserialize( return true; } -std::function float_externalPubSubType::getSerializedSizeProvider( +uint32_t float_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* float_externalPubSubType::createData() + 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* float_externalPubSubType::create_data() { return reinterpret_cast(new float_external()); } -void float_externalPubSubType::deleteData( +void float_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool float_externalPubSubType::getKey( +bool float_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + float_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool float_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1347,35 +1264,27 @@ bool float_externalPubSubType::getKey( const float_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), float_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || float_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1389,49 +1298,42 @@ void float_externalPubSubType::register_type_object_representation() double_externalPubSubType::double_externalPubSubType() { - setName("double_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(double_external::getMaxCdrSerializedSize()); -#else - double_external_max_cdr_typesize; -#endif + set_name("double_external"); + uint32_t type_size = double_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = double_external_max_key_cdr_typesize > 16 ? double_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = double_external_max_key_cdr_typesize > 16 ? double_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } double_externalPubSubType::~double_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool double_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const double_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1446,16 +1348,12 @@ bool double_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool double_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1464,18 +1362,14 @@ bool double_externalPubSubType::deserialize( double_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1488,52 +1382,62 @@ bool double_externalPubSubType::deserialize( return true; } -std::function double_externalPubSubType::getSerializedSizeProvider( +uint32_t double_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* double_externalPubSubType::createData() + 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* double_externalPubSubType::create_data() { return reinterpret_cast(new double_external()); } -void double_externalPubSubType::deleteData( +void double_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool double_externalPubSubType::getKey( +bool double_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + double_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool double_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1541,35 +1445,27 @@ bool double_externalPubSubType::getKey( const double_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), double_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || double_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1583,49 +1479,42 @@ void double_externalPubSubType::register_type_object_representation() longdouble_externalPubSubType::longdouble_externalPubSubType() { - setName("longdouble_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(longdouble_external::getMaxCdrSerializedSize()); -#else - longdouble_external_max_cdr_typesize; -#endif + set_name("longdouble_external"); + uint32_t type_size = longdouble_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = longdouble_external_max_key_cdr_typesize > 16 ? longdouble_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = longdouble_external_max_key_cdr_typesize > 16 ? longdouble_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } longdouble_externalPubSubType::~longdouble_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool longdouble_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const longdouble_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1640,16 +1529,12 @@ bool longdouble_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool longdouble_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1658,18 +1543,14 @@ bool longdouble_externalPubSubType::deserialize( longdouble_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1682,52 +1563,62 @@ bool longdouble_externalPubSubType::deserialize( return true; } -std::function longdouble_externalPubSubType::getSerializedSizeProvider( +uint32_t longdouble_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* longdouble_externalPubSubType::createData() + 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* longdouble_externalPubSubType::create_data() { return reinterpret_cast(new longdouble_external()); } -void longdouble_externalPubSubType::deleteData( +void longdouble_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool longdouble_externalPubSubType::getKey( +bool longdouble_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + longdouble_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool longdouble_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1735,35 +1626,27 @@ bool longdouble_externalPubSubType::getKey( const longdouble_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), longdouble_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || longdouble_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1777,49 +1660,42 @@ void longdouble_externalPubSubType::register_type_object_representation() boolean_externalPubSubType::boolean_externalPubSubType() { - setName("boolean_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(boolean_external::getMaxCdrSerializedSize()); -#else - boolean_external_max_cdr_typesize; -#endif + set_name("boolean_external"); + uint32_t type_size = boolean_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = boolean_external_max_key_cdr_typesize > 16 ? boolean_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = boolean_external_max_key_cdr_typesize > 16 ? boolean_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } boolean_externalPubSubType::~boolean_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool boolean_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const boolean_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1834,16 +1710,12 @@ bool boolean_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool boolean_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1852,18 +1724,14 @@ bool boolean_externalPubSubType::deserialize( boolean_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1876,52 +1744,62 @@ bool boolean_externalPubSubType::deserialize( return true; } -std::function boolean_externalPubSubType::getSerializedSizeProvider( +uint32_t boolean_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* boolean_externalPubSubType::createData() + 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* boolean_externalPubSubType::create_data() { return reinterpret_cast(new boolean_external()); } -void boolean_externalPubSubType::deleteData( +void boolean_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool boolean_externalPubSubType::getKey( +bool boolean_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + boolean_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool boolean_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1929,35 +1807,27 @@ bool boolean_externalPubSubType::getKey( const boolean_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), boolean_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || boolean_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1971,49 +1841,42 @@ void boolean_externalPubSubType::register_type_object_representation() octet_externalPubSubType::octet_externalPubSubType() { - setName("octet_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(octet_external::getMaxCdrSerializedSize()); -#else - octet_external_max_cdr_typesize; -#endif + set_name("octet_external"); + uint32_t type_size = octet_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = octet_external_max_key_cdr_typesize > 16 ? octet_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = octet_external_max_key_cdr_typesize > 16 ? octet_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } octet_externalPubSubType::~octet_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool octet_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const octet_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2028,16 +1891,12 @@ bool octet_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool octet_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2046,18 +1905,14 @@ bool octet_externalPubSubType::deserialize( octet_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2070,52 +1925,62 @@ bool octet_externalPubSubType::deserialize( return true; } -std::function octet_externalPubSubType::getSerializedSizeProvider( +uint32_t octet_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* octet_externalPubSubType::createData() + 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* octet_externalPubSubType::create_data() { return reinterpret_cast(new octet_external()); } -void octet_externalPubSubType::deleteData( +void octet_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool octet_externalPubSubType::getKey( +bool octet_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + octet_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool octet_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2123,35 +1988,27 @@ bool octet_externalPubSubType::getKey( const octet_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), octet_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || octet_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2165,49 +2022,42 @@ void octet_externalPubSubType::register_type_object_representation() char_externalPubSubType::char_externalPubSubType() { - setName("char_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(char_external::getMaxCdrSerializedSize()); -#else - char_external_max_cdr_typesize; -#endif + set_name("char_external"); + uint32_t type_size = char_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = char_external_max_key_cdr_typesize > 16 ? char_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = char_external_max_key_cdr_typesize > 16 ? char_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } char_externalPubSubType::~char_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool char_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const char_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2222,16 +2072,12 @@ bool char_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool char_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2240,18 +2086,14 @@ bool char_externalPubSubType::deserialize( char_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2264,52 +2106,62 @@ bool char_externalPubSubType::deserialize( return true; } -std::function char_externalPubSubType::getSerializedSizeProvider( +uint32_t char_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* char_externalPubSubType::createData() + 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* char_externalPubSubType::create_data() { return reinterpret_cast(new char_external()); } -void char_externalPubSubType::deleteData( +void char_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool char_externalPubSubType::getKey( +bool char_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + char_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool char_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2317,35 +2169,27 @@ bool char_externalPubSubType::getKey( const char_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), char_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || char_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2359,49 +2203,42 @@ void char_externalPubSubType::register_type_object_representation() wchar_externalPubSubType::wchar_externalPubSubType() { - setName("wchar_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(wchar_external::getMaxCdrSerializedSize()); -#else - wchar_external_max_cdr_typesize; -#endif + set_name("wchar_external"); + uint32_t type_size = wchar_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = wchar_external_max_key_cdr_typesize > 16 ? wchar_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = wchar_external_max_key_cdr_typesize > 16 ? wchar_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } wchar_externalPubSubType::~wchar_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool wchar_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const wchar_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2416,16 +2253,12 @@ bool wchar_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool wchar_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2434,18 +2267,14 @@ bool wchar_externalPubSubType::deserialize( wchar_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2458,88 +2287,90 @@ bool wchar_externalPubSubType::deserialize( return true; } -std::function wchar_externalPubSubType::getSerializedSizeProvider( +uint32_t wchar_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* wchar_externalPubSubType::createData() + 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* wchar_externalPubSubType::create_data() { return reinterpret_cast(new wchar_external()); } -void wchar_externalPubSubType::deleteData( +void wchar_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool wchar_externalPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, +bool wchar_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const wchar_external* p_type = static_cast(data); + wchar_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - wchar_external_max_key_cdr_typesize); + return false; +} + +bool wchar_externalPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const wchar_external* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + wchar_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || wchar_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2553,49 +2384,42 @@ void wchar_externalPubSubType::register_type_object_representation() sequence_short_externalPubSubType::sequence_short_externalPubSubType() { - setName("sequence_short_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sequence_short_external::getMaxCdrSerializedSize()); -#else - sequence_short_external_max_cdr_typesize; -#endif + set_name("sequence_short_external"); + uint32_t type_size = sequence_short_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = sequence_short_external_max_key_cdr_typesize > 16 ? sequence_short_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = sequence_short_external_max_key_cdr_typesize > 16 ? sequence_short_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } sequence_short_externalPubSubType::~sequence_short_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool sequence_short_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const sequence_short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2610,16 +2434,12 @@ bool sequence_short_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool sequence_short_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2628,18 +2448,14 @@ bool sequence_short_externalPubSubType::deserialize( sequence_short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2652,52 +2468,62 @@ bool sequence_short_externalPubSubType::deserialize( return true; } -std::function sequence_short_externalPubSubType::getSerializedSizeProvider( +uint32_t sequence_short_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* sequence_short_externalPubSubType::createData() + 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* sequence_short_externalPubSubType::create_data() { return reinterpret_cast(new sequence_short_external()); } -void sequence_short_externalPubSubType::deleteData( +void sequence_short_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool sequence_short_externalPubSubType::getKey( +bool sequence_short_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + sequence_short_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool sequence_short_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2705,35 +2531,27 @@ bool sequence_short_externalPubSubType::getKey( const sequence_short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), sequence_short_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || sequence_short_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2747,49 +2565,42 @@ void sequence_short_externalPubSubType::register_type_object_representation() string_unbounded_externalPubSubType::string_unbounded_externalPubSubType() { - setName("string_unbounded_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(string_unbounded_external::getMaxCdrSerializedSize()); -#else - string_unbounded_external_max_cdr_typesize; -#endif + set_name("string_unbounded_external"); + uint32_t type_size = string_unbounded_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = string_unbounded_external_max_key_cdr_typesize > 16 ? string_unbounded_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = string_unbounded_external_max_key_cdr_typesize > 16 ? string_unbounded_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } string_unbounded_externalPubSubType::~string_unbounded_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool string_unbounded_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const string_unbounded_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2804,16 +2615,12 @@ bool string_unbounded_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool string_unbounded_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2822,18 +2629,14 @@ bool string_unbounded_externalPubSubType::deserialize( string_unbounded_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2846,52 +2649,62 @@ bool string_unbounded_externalPubSubType::deserialize( return true; } -std::function string_unbounded_externalPubSubType::getSerializedSizeProvider( +uint32_t string_unbounded_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* string_unbounded_externalPubSubType::createData() + 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* string_unbounded_externalPubSubType::create_data() { return reinterpret_cast(new string_unbounded_external()); } -void string_unbounded_externalPubSubType::deleteData( +void string_unbounded_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool string_unbounded_externalPubSubType::getKey( +bool string_unbounded_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + string_unbounded_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool string_unbounded_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2899,35 +2712,27 @@ bool string_unbounded_externalPubSubType::getKey( const string_unbounded_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), string_unbounded_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || string_unbounded_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2941,49 +2746,42 @@ void string_unbounded_externalPubSubType::register_type_object_representation() string_bounded_externalPubSubType::string_bounded_externalPubSubType() { - setName("string_bounded_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(string_bounded_external::getMaxCdrSerializedSize()); -#else - string_bounded_external_max_cdr_typesize; -#endif + set_name("string_bounded_external"); + uint32_t type_size = string_bounded_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = string_bounded_external_max_key_cdr_typesize > 16 ? string_bounded_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = string_bounded_external_max_key_cdr_typesize > 16 ? string_bounded_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } string_bounded_externalPubSubType::~string_bounded_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool string_bounded_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const string_bounded_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2998,16 +2796,12 @@ bool string_bounded_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool string_bounded_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3016,18 +2810,14 @@ bool string_bounded_externalPubSubType::deserialize( string_bounded_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3040,52 +2830,62 @@ bool string_bounded_externalPubSubType::deserialize( return true; } -std::function string_bounded_externalPubSubType::getSerializedSizeProvider( +uint32_t string_bounded_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* string_bounded_externalPubSubType::createData() + 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* string_bounded_externalPubSubType::create_data() { return reinterpret_cast(new string_bounded_external()); } -void string_bounded_externalPubSubType::deleteData( +void string_bounded_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool string_bounded_externalPubSubType::getKey( +bool string_bounded_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + string_bounded_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool string_bounded_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3093,35 +2893,27 @@ bool string_bounded_externalPubSubType::getKey( const string_bounded_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), string_bounded_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || string_bounded_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3135,49 +2927,42 @@ void string_bounded_externalPubSubType::register_type_object_representation() map_short_externalPubSubType::map_short_externalPubSubType() { - setName("map_short_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(map_short_external::getMaxCdrSerializedSize()); -#else - map_short_external_max_cdr_typesize; -#endif + set_name("map_short_external"); + uint32_t type_size = map_short_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = map_short_external_max_key_cdr_typesize > 16 ? map_short_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = map_short_external_max_key_cdr_typesize > 16 ? map_short_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } map_short_externalPubSubType::~map_short_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool map_short_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const map_short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3192,16 +2977,12 @@ bool map_short_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool map_short_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3210,18 +2991,14 @@ bool map_short_externalPubSubType::deserialize( map_short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3234,52 +3011,62 @@ bool map_short_externalPubSubType::deserialize( return true; } -std::function map_short_externalPubSubType::getSerializedSizeProvider( +uint32_t map_short_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* map_short_externalPubSubType::createData() + 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* map_short_externalPubSubType::create_data() { return reinterpret_cast(new map_short_external()); } -void map_short_externalPubSubType::deleteData( +void map_short_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool map_short_externalPubSubType::getKey( +bool map_short_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + map_short_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool map_short_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3287,35 +3074,27 @@ bool map_short_externalPubSubType::getKey( const map_short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), map_short_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || map_short_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3329,49 +3108,42 @@ void map_short_externalPubSubType::register_type_object_representation() array_short_externalPubSubType::array_short_externalPubSubType() { - setName("array_short_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(array_short_external::getMaxCdrSerializedSize()); -#else - array_short_external_max_cdr_typesize; -#endif + set_name("array_short_external"); + uint32_t type_size = array_short_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = array_short_external_max_key_cdr_typesize > 16 ? array_short_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = array_short_external_max_key_cdr_typesize > 16 ? array_short_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } array_short_externalPubSubType::~array_short_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool array_short_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const array_short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3386,16 +3158,12 @@ bool array_short_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool array_short_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3404,18 +3172,14 @@ bool array_short_externalPubSubType::deserialize( array_short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3428,52 +3192,62 @@ bool array_short_externalPubSubType::deserialize( return true; } -std::function array_short_externalPubSubType::getSerializedSizeProvider( +uint32_t array_short_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* array_short_externalPubSubType::createData() + 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* array_short_externalPubSubType::create_data() { return reinterpret_cast(new array_short_external()); } -void array_short_externalPubSubType::deleteData( +void array_short_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool array_short_externalPubSubType::getKey( +bool array_short_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + array_short_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool array_short_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3481,35 +3255,27 @@ bool array_short_externalPubSubType::getKey( const array_short_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), array_short_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || array_short_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3523,49 +3289,42 @@ void array_short_externalPubSubType::register_type_object_representation() struct_externalPubSubType::struct_externalPubSubType() { - setName("struct_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(struct_external::getMaxCdrSerializedSize()); -#else - struct_external_max_cdr_typesize; -#endif + set_name("struct_external"); + uint32_t type_size = struct_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = struct_external_max_key_cdr_typesize > 16 ? struct_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = struct_external_max_key_cdr_typesize > 16 ? struct_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } struct_externalPubSubType::~struct_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool struct_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const struct_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3580,16 +3339,12 @@ bool struct_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool struct_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3598,18 +3353,14 @@ bool struct_externalPubSubType::deserialize( struct_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3622,52 +3373,62 @@ bool struct_externalPubSubType::deserialize( return true; } -std::function struct_externalPubSubType::getSerializedSizeProvider( +uint32_t struct_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* struct_externalPubSubType::createData() + 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* struct_externalPubSubType::create_data() { return reinterpret_cast(new struct_external()); } -void struct_externalPubSubType::deleteData( +void struct_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool struct_externalPubSubType::getKey( +bool struct_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + struct_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool struct_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3675,35 +3436,27 @@ bool struct_externalPubSubType::getKey( const struct_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), struct_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || struct_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3717,49 +3470,42 @@ void struct_externalPubSubType::register_type_object_representation() InnerStructExternalPubSubType::InnerStructExternalPubSubType() { - setName("InnerStructExternal"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InnerStructExternal::getMaxCdrSerializedSize()); -#else - InnerStructExternal_max_cdr_typesize; -#endif + set_name("InnerStructExternal"); + uint32_t type_size = InnerStructExternal_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = InnerStructExternal_max_key_cdr_typesize > 16 ? InnerStructExternal_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = InnerStructExternal_max_key_cdr_typesize > 16 ? InnerStructExternal_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InnerStructExternalPubSubType::~InnerStructExternalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InnerStructExternalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InnerStructExternal* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3774,16 +3520,12 @@ bool InnerStructExternalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InnerStructExternalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3792,18 +3534,14 @@ bool InnerStructExternalPubSubType::deserialize( InnerStructExternal* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3816,52 +3554,62 @@ bool InnerStructExternalPubSubType::deserialize( return true; } -std::function InnerStructExternalPubSubType::getSerializedSizeProvider( +uint32_t InnerStructExternalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* InnerStructExternalPubSubType::createData() + 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* InnerStructExternalPubSubType::create_data() { return reinterpret_cast(new InnerStructExternal()); } -void InnerStructExternalPubSubType::deleteData( +void InnerStructExternalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InnerStructExternalPubSubType::getKey( +bool InnerStructExternalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InnerStructExternal data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InnerStructExternalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3869,35 +3617,27 @@ bool InnerStructExternalPubSubType::getKey( const InnerStructExternal* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InnerStructExternal_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InnerStructExternal_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3911,49 +3651,42 @@ void InnerStructExternalPubSubType::register_type_object_representation() ext_struct_externalPubSubType::ext_struct_externalPubSubType() { - setName("ext_struct_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ext_struct_external::getMaxCdrSerializedSize()); -#else - ext_struct_external_max_cdr_typesize; -#endif + set_name("ext_struct_external"); + uint32_t type_size = ext_struct_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ext_struct_external_max_key_cdr_typesize > 16 ? ext_struct_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ext_struct_external_max_key_cdr_typesize > 16 ? ext_struct_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ext_struct_externalPubSubType::~ext_struct_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ext_struct_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ext_struct_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3968,16 +3701,12 @@ bool ext_struct_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ext_struct_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3986,18 +3715,14 @@ bool ext_struct_externalPubSubType::deserialize( ext_struct_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4010,52 +3735,62 @@ bool ext_struct_externalPubSubType::deserialize( return true; } -std::function ext_struct_externalPubSubType::getSerializedSizeProvider( +uint32_t ext_struct_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ext_struct_externalPubSubType::createData() + 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* ext_struct_externalPubSubType::create_data() { return reinterpret_cast(new ext_struct_external()); } -void ext_struct_externalPubSubType::deleteData( +void ext_struct_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ext_struct_externalPubSubType::getKey( +bool ext_struct_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ext_struct_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ext_struct_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4063,35 +3798,27 @@ bool ext_struct_externalPubSubType::getKey( const ext_struct_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ext_struct_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ext_struct_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4105,49 +3832,42 @@ void ext_struct_externalPubSubType::register_type_object_representation() ext_and_inner_struct_externalPubSubType::ext_and_inner_struct_externalPubSubType() { - setName("ext_and_inner_struct_external"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ext_and_inner_struct_external::getMaxCdrSerializedSize()); -#else - ext_and_inner_struct_external_max_cdr_typesize; -#endif + set_name("ext_and_inner_struct_external"); + uint32_t type_size = ext_and_inner_struct_external_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ext_and_inner_struct_external_max_key_cdr_typesize > 16 ? ext_and_inner_struct_external_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ext_and_inner_struct_external_max_key_cdr_typesize > 16 ? ext_and_inner_struct_external_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ext_and_inner_struct_externalPubSubType::~ext_and_inner_struct_externalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ext_and_inner_struct_externalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ext_and_inner_struct_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4162,16 +3882,12 @@ bool ext_and_inner_struct_externalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ext_and_inner_struct_externalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4180,18 +3896,14 @@ bool ext_and_inner_struct_externalPubSubType::deserialize( ext_and_inner_struct_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4204,52 +3916,62 @@ bool ext_and_inner_struct_externalPubSubType::deserialize( return true; } -std::function ext_and_inner_struct_externalPubSubType::getSerializedSizeProvider( +uint32_t ext_and_inner_struct_externalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ext_and_inner_struct_externalPubSubType::createData() + 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* ext_and_inner_struct_externalPubSubType::create_data() { return reinterpret_cast(new ext_and_inner_struct_external()); } -void ext_and_inner_struct_externalPubSubType::deleteData( +void ext_and_inner_struct_externalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ext_and_inner_struct_externalPubSubType::getKey( +bool ext_and_inner_struct_externalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ext_and_inner_struct_external data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ext_and_inner_struct_externalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4257,35 +3979,27 @@ bool ext_and_inner_struct_externalPubSubType::getKey( const ext_and_inner_struct_external* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ext_and_inner_struct_external_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ext_and_inner_struct_external_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4299,49 +4013,42 @@ void ext_and_inner_struct_externalPubSubType::register_type_object_representatio struct_external_optionalPubSubType::struct_external_optionalPubSubType() { - setName("struct_external_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(struct_external_optional::getMaxCdrSerializedSize()); -#else - struct_external_optional_max_cdr_typesize; -#endif + set_name("struct_external_optional"); + uint32_t type_size = struct_external_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = struct_external_optional_max_key_cdr_typesize > 16 ? struct_external_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = struct_external_optional_max_key_cdr_typesize > 16 ? struct_external_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } struct_external_optionalPubSubType::~struct_external_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool struct_external_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const struct_external_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4356,16 +4063,12 @@ bool struct_external_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool struct_external_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4374,18 +4077,14 @@ bool struct_external_optionalPubSubType::deserialize( struct_external_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4398,52 +4097,62 @@ bool struct_external_optionalPubSubType::deserialize( return true; } -std::function struct_external_optionalPubSubType::getSerializedSizeProvider( +uint32_t struct_external_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* struct_external_optionalPubSubType::createData() + 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* struct_external_optionalPubSubType::create_data() { return reinterpret_cast(new struct_external_optional()); } -void struct_external_optionalPubSubType::deleteData( +void struct_external_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool struct_external_optionalPubSubType::getKey( +bool struct_external_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + struct_external_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool struct_external_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4451,35 +4160,27 @@ bool struct_external_optionalPubSubType::getKey( const struct_external_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), struct_external_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || struct_external_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4494,49 +4195,42 @@ void struct_external_optionalPubSubType::register_type_object_representation() recursive_union_containerPubSubType::recursive_union_containerPubSubType() { - setName("recursive_union_container"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(recursive_union_container::getMaxCdrSerializedSize()); -#else - recursive_union_container_max_cdr_typesize; -#endif + set_name("recursive_union_container"); + uint32_t type_size = recursive_union_container_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = recursive_union_container_max_key_cdr_typesize > 16 ? recursive_union_container_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = recursive_union_container_max_key_cdr_typesize > 16 ? recursive_union_container_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } recursive_union_containerPubSubType::~recursive_union_containerPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool recursive_union_containerPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const recursive_union_container* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4551,16 +4245,12 @@ bool recursive_union_containerPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool recursive_union_containerPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4569,18 +4259,14 @@ bool recursive_union_containerPubSubType::deserialize( recursive_union_container* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4593,52 +4279,62 @@ bool recursive_union_containerPubSubType::deserialize( return true; } -std::function recursive_union_containerPubSubType::getSerializedSizeProvider( +uint32_t recursive_union_containerPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* recursive_union_containerPubSubType::createData() + 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* recursive_union_containerPubSubType::create_data() { return reinterpret_cast(new recursive_union_container()); } -void recursive_union_containerPubSubType::deleteData( +void recursive_union_containerPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool recursive_union_containerPubSubType::getKey( +bool recursive_union_containerPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + recursive_union_container data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool recursive_union_containerPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4646,35 +4342,27 @@ bool recursive_union_containerPubSubType::getKey( const recursive_union_container* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), recursive_union_container_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || recursive_union_container_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4689,49 +4377,42 @@ void recursive_union_containerPubSubType::register_type_object_representation() recursive_test_1PubSubType::recursive_test_1PubSubType() { - setName("recursive_test_1"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(recursive_test_1::getMaxCdrSerializedSize()); -#else - recursive_test_1_max_cdr_typesize; -#endif + set_name("recursive_test_1"); + uint32_t type_size = recursive_test_1_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = recursive_test_1_max_key_cdr_typesize > 16 ? recursive_test_1_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = recursive_test_1_max_key_cdr_typesize > 16 ? recursive_test_1_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } recursive_test_1PubSubType::~recursive_test_1PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool recursive_test_1PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const recursive_test_1* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4746,16 +4427,12 @@ bool recursive_test_1PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool recursive_test_1PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4764,18 +4441,14 @@ bool recursive_test_1PubSubType::deserialize( recursive_test_1* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4788,52 +4461,62 @@ bool recursive_test_1PubSubType::deserialize( return true; } -std::function recursive_test_1PubSubType::getSerializedSizeProvider( +uint32_t recursive_test_1PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* recursive_test_1PubSubType::createData() + 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* recursive_test_1PubSubType::create_data() { return reinterpret_cast(new recursive_test_1()); } -void recursive_test_1PubSubType::deleteData( +void recursive_test_1PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool recursive_test_1PubSubType::getKey( +bool recursive_test_1PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + recursive_test_1 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool recursive_test_1PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4841,35 +4524,27 @@ bool recursive_test_1PubSubType::getKey( const recursive_test_1* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), recursive_test_1_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || recursive_test_1_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4885,49 +4560,42 @@ void recursive_test_1PubSubType::register_type_object_representation() recursive_structurePubSubType::recursive_structurePubSubType() { - setName("recursive_structure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(recursive_structure::getMaxCdrSerializedSize()); -#else - recursive_structure_max_cdr_typesize; -#endif + set_name("recursive_structure"); + uint32_t type_size = recursive_structure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = recursive_structure_max_key_cdr_typesize > 16 ? recursive_structure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = recursive_structure_max_key_cdr_typesize > 16 ? recursive_structure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } recursive_structurePubSubType::~recursive_structurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool recursive_structurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const recursive_structure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4942,16 +4610,12 @@ bool recursive_structurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool recursive_structurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4960,18 +4624,14 @@ bool recursive_structurePubSubType::deserialize( recursive_structure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4984,52 +4644,62 @@ bool recursive_structurePubSubType::deserialize( return true; } -std::function recursive_structurePubSubType::getSerializedSizeProvider( +uint32_t recursive_structurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* recursive_structurePubSubType::createData() + 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* recursive_structurePubSubType::create_data() { return reinterpret_cast(new recursive_structure()); } -void recursive_structurePubSubType::deleteData( +void recursive_structurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool recursive_structurePubSubType::getKey( +bool recursive_structurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + recursive_structure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool recursive_structurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5037,35 +4707,27 @@ bool recursive_structurePubSubType::getKey( const recursive_structure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), recursive_structure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || recursive_structure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5079,49 +4741,42 @@ void recursive_structurePubSubType::register_type_object_representation() recursive_test_2PubSubType::recursive_test_2PubSubType() { - setName("recursive_test_2"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(recursive_test_2::getMaxCdrSerializedSize()); -#else - recursive_test_2_max_cdr_typesize; -#endif + set_name("recursive_test_2"); + uint32_t type_size = recursive_test_2_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = recursive_test_2_max_key_cdr_typesize > 16 ? recursive_test_2_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = recursive_test_2_max_key_cdr_typesize > 16 ? recursive_test_2_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } recursive_test_2PubSubType::~recursive_test_2PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool recursive_test_2PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const recursive_test_2* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5136,16 +4791,12 @@ bool recursive_test_2PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool recursive_test_2PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5154,18 +4805,14 @@ bool recursive_test_2PubSubType::deserialize( recursive_test_2* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5178,52 +4825,62 @@ bool recursive_test_2PubSubType::deserialize( return true; } -std::function recursive_test_2PubSubType::getSerializedSizeProvider( +uint32_t recursive_test_2PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* recursive_test_2PubSubType::createData() + 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* recursive_test_2PubSubType::create_data() { return reinterpret_cast(new recursive_test_2()); } -void recursive_test_2PubSubType::deleteData( +void recursive_test_2PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool recursive_test_2PubSubType::getKey( +bool recursive_test_2PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + recursive_test_2 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool recursive_test_2PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5231,35 +4888,27 @@ bool recursive_test_2PubSubType::getKey( const recursive_test_2* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), recursive_test_2_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || recursive_test_2_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/externalPubSubTypes.hpp b/test/dds-types-test/externalPubSubTypes.hpp index ddab0c35114..95328b37a01 100644 --- a/test/dds-types-test/externalPubSubTypes.hpp +++ b/test/dds-types-test/externalPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated external is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class short_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class short_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class short_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class ushort_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class ushort_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class ushort_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -237,38 +217,30 @@ class long_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -283,10 +255,6 @@ class long_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,8 +275,10 @@ class long_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -328,38 +298,30 @@ class ulong_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -374,10 +336,6 @@ class ulong_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -398,8 +356,10 @@ class ulong_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -419,38 +379,30 @@ class longlong_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -465,10 +417,6 @@ class longlong_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -489,8 +437,10 @@ class longlong_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -510,38 +460,30 @@ class ulonglong_externalPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -556,10 +498,6 @@ class ulonglong_externalPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -580,8 +518,10 @@ class ulonglong_externalPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -601,38 +541,30 @@ class float_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -647,10 +579,6 @@ class float_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -671,8 +599,10 @@ class float_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -692,38 +622,30 @@ class double_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -738,10 +660,6 @@ class double_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -762,8 +680,10 @@ class double_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -783,38 +703,30 @@ class longdouble_externalPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -829,10 +741,6 @@ class longdouble_externalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -853,8 +761,10 @@ class longdouble_externalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -874,38 +784,30 @@ class boolean_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -920,10 +822,6 @@ class boolean_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -944,8 +842,10 @@ class boolean_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -965,38 +865,30 @@ class octet_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1011,10 +903,6 @@ class octet_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1035,8 +923,10 @@ class octet_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1056,38 +946,30 @@ class char_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1102,10 +984,6 @@ class char_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1126,8 +1004,10 @@ class char_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1147,38 +1027,30 @@ class wchar_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1193,10 +1065,6 @@ class wchar_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1217,8 +1085,10 @@ class wchar_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1238,38 +1108,30 @@ class sequence_short_externalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1284,10 +1146,6 @@ class sequence_short_externalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1308,8 +1166,10 @@ class sequence_short_externalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1329,38 +1189,30 @@ class string_unbounded_externalPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1375,10 +1227,6 @@ class string_unbounded_externalPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1399,8 +1247,10 @@ class string_unbounded_externalPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1420,38 +1270,30 @@ class string_bounded_externalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1466,10 +1308,6 @@ class string_bounded_externalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1490,8 +1328,10 @@ class string_bounded_externalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1511,38 +1351,30 @@ class map_short_externalPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1557,10 +1389,6 @@ class map_short_externalPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1581,8 +1409,10 @@ class map_short_externalPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1602,38 +1432,30 @@ class array_short_externalPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1648,10 +1470,6 @@ class array_short_externalPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1672,8 +1490,10 @@ class array_short_externalPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1693,38 +1513,30 @@ class struct_externalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1739,10 +1551,6 @@ class struct_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1763,8 +1571,10 @@ class struct_externalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1784,38 +1594,30 @@ class InnerStructExternalPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1830,10 +1632,6 @@ class InnerStructExternalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1854,8 +1652,10 @@ class InnerStructExternalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1875,38 +1675,30 @@ class ext_struct_externalPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1921,10 +1713,6 @@ class ext_struct_externalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1945,8 +1733,10 @@ class ext_struct_externalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1966,38 +1756,30 @@ class ext_and_inner_struct_externalPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2012,10 +1794,6 @@ class ext_and_inner_struct_externalPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2036,8 +1814,10 @@ class ext_and_inner_struct_externalPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2057,38 +1837,30 @@ class struct_external_optionalPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2103,10 +1875,6 @@ class struct_external_optionalPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2127,8 +1895,10 @@ class struct_external_optionalPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2149,38 +1919,30 @@ class recursive_union_containerPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2195,10 +1957,6 @@ class recursive_union_containerPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2219,8 +1977,10 @@ class recursive_union_containerPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2241,38 +2001,30 @@ class recursive_test_1PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2287,10 +2039,6 @@ class recursive_test_1PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2311,8 +2059,10 @@ class recursive_test_1PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2334,38 +2084,30 @@ class recursive_structurePubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2380,10 +2122,6 @@ class recursive_structurePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2404,8 +2142,10 @@ class recursive_structurePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2425,38 +2165,30 @@ class recursive_test_2PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2471,10 +2203,6 @@ class recursive_test_2PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2495,8 +2223,10 @@ class recursive_test_2PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/finalPubSubTypes.cxx b/test/dds-types-test/finalPubSubTypes.cxx index e83b5ae42c3..34a346933f5 100644 --- a/test/dds-types-test/finalPubSubTypes.cxx +++ b/test/dds-types-test/finalPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; FinalShortStructPubSubType::FinalShortStructPubSubType() { - setName("FinalShortStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalShortStruct::getMaxCdrSerializedSize()); -#else - FinalShortStruct_max_cdr_typesize; -#endif + set_name("FinalShortStruct"); + uint32_t type_size = FinalShortStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalShortStruct_max_key_cdr_typesize > 16 ? FinalShortStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalShortStruct_max_key_cdr_typesize > 16 ? FinalShortStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalShortStructPubSubType::~FinalShortStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalShortStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool FinalShortStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalShortStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool FinalShortStructPubSubType::deserialize( FinalShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool FinalShortStructPubSubType::deserialize( return true; } -std::function FinalShortStructPubSubType::getSerializedSizeProvider( +uint32_t FinalShortStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalShortStructPubSubType::createData() + 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* FinalShortStructPubSubType::create_data() { return reinterpret_cast(new FinalShortStruct()); } -void FinalShortStructPubSubType::deleteData( +void FinalShortStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalShortStructPubSubType::getKey( +bool FinalShortStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalShortStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalShortStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool FinalShortStructPubSubType::getKey( const FinalShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalShortStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalShortStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void FinalShortStructPubSubType::register_type_object_representation() FinalUShortStructPubSubType::FinalUShortStructPubSubType() { - setName("FinalUShortStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalUShortStruct::getMaxCdrSerializedSize()); -#else - FinalUShortStruct_max_cdr_typesize; -#endif + set_name("FinalUShortStruct"); + uint32_t type_size = FinalUShortStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalUShortStruct_max_key_cdr_typesize > 16 ? FinalUShortStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalUShortStruct_max_key_cdr_typesize > 16 ? FinalUShortStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalUShortStructPubSubType::~FinalUShortStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalUShortStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool FinalUShortStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalUShortStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool FinalUShortStructPubSubType::deserialize( FinalUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool FinalUShortStructPubSubType::deserialize( return true; } -std::function FinalUShortStructPubSubType::getSerializedSizeProvider( +uint32_t FinalUShortStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalUShortStructPubSubType::createData() + 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* FinalUShortStructPubSubType::create_data() { return reinterpret_cast(new FinalUShortStruct()); } -void FinalUShortStructPubSubType::deleteData( +void FinalUShortStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalUShortStructPubSubType::getKey( +bool FinalUShortStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalUShortStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalUShortStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool FinalUShortStructPubSubType::getKey( const FinalUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalUShortStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalUShortStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void FinalUShortStructPubSubType::register_type_object_representation() FinalLongStructPubSubType::FinalLongStructPubSubType() { - setName("FinalLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalLongStruct::getMaxCdrSerializedSize()); -#else - FinalLongStruct_max_cdr_typesize; -#endif + set_name("FinalLongStruct"); + uint32_t type_size = FinalLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalLongStruct_max_key_cdr_typesize > 16 ? FinalLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalLongStruct_max_key_cdr_typesize > 16 ? FinalLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalLongStructPubSubType::~FinalLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool FinalLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool FinalLongStructPubSubType::deserialize( FinalLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool FinalLongStructPubSubType::deserialize( return true; } -std::function FinalLongStructPubSubType::getSerializedSizeProvider( +uint32_t FinalLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalLongStructPubSubType::createData() + 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* FinalLongStructPubSubType::create_data() { return reinterpret_cast(new FinalLongStruct()); } -void FinalLongStructPubSubType::deleteData( +void FinalLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalLongStructPubSubType::getKey( +bool FinalLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool FinalLongStructPubSubType::getKey( const FinalLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void FinalLongStructPubSubType::register_type_object_representation() FinalULongStructPubSubType::FinalULongStructPubSubType() { - setName("FinalULongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalULongStruct::getMaxCdrSerializedSize()); -#else - FinalULongStruct_max_cdr_typesize; -#endif + set_name("FinalULongStruct"); + uint32_t type_size = FinalULongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalULongStruct_max_key_cdr_typesize > 16 ? FinalULongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalULongStruct_max_key_cdr_typesize > 16 ? FinalULongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalULongStructPubSubType::~FinalULongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalULongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool FinalULongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalULongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool FinalULongStructPubSubType::deserialize( FinalULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool FinalULongStructPubSubType::deserialize( return true; } -std::function FinalULongStructPubSubType::getSerializedSizeProvider( +uint32_t FinalULongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalULongStructPubSubType::createData() + 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* FinalULongStructPubSubType::create_data() { return reinterpret_cast(new FinalULongStruct()); } -void FinalULongStructPubSubType::deleteData( +void FinalULongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalULongStructPubSubType::getKey( +bool FinalULongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalULongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalULongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool FinalULongStructPubSubType::getKey( const FinalULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalULongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalULongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void FinalULongStructPubSubType::register_type_object_representation() FinalLongLongStructPubSubType::FinalLongLongStructPubSubType() { - setName("FinalLongLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalLongLongStruct::getMaxCdrSerializedSize()); -#else - FinalLongLongStruct_max_cdr_typesize; -#endif + set_name("FinalLongLongStruct"); + uint32_t type_size = FinalLongLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalLongLongStruct_max_key_cdr_typesize > 16 ? FinalLongLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalLongLongStruct_max_key_cdr_typesize > 16 ? FinalLongLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalLongLongStructPubSubType::~FinalLongLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalLongLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool FinalLongLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalLongLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool FinalLongLongStructPubSubType::deserialize( FinalLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool FinalLongLongStructPubSubType::deserialize( return true; } -std::function FinalLongLongStructPubSubType::getSerializedSizeProvider( +uint32_t FinalLongLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalLongLongStructPubSubType::createData() + 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* FinalLongLongStructPubSubType::create_data() { return reinterpret_cast(new FinalLongLongStruct()); } -void FinalLongLongStructPubSubType::deleteData( +void FinalLongLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalLongLongStructPubSubType::getKey( +bool FinalLongLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalLongLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalLongLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool FinalLongLongStructPubSubType::getKey( const FinalLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalLongLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalLongLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void FinalLongLongStructPubSubType::register_type_object_representation() FinalULongLongStructPubSubType::FinalULongLongStructPubSubType() { - setName("FinalULongLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalULongLongStruct::getMaxCdrSerializedSize()); -#else - FinalULongLongStruct_max_cdr_typesize; -#endif + set_name("FinalULongLongStruct"); + uint32_t type_size = FinalULongLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalULongLongStruct_max_key_cdr_typesize > 16 ? FinalULongLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalULongLongStruct_max_key_cdr_typesize > 16 ? FinalULongLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalULongLongStructPubSubType::~FinalULongLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalULongLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool FinalULongLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalULongLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool FinalULongLongStructPubSubType::deserialize( FinalULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool FinalULongLongStructPubSubType::deserialize( return true; } -std::function FinalULongLongStructPubSubType::getSerializedSizeProvider( +uint32_t FinalULongLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalULongLongStructPubSubType::createData() + 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* FinalULongLongStructPubSubType::create_data() { return reinterpret_cast(new FinalULongLongStruct()); } -void FinalULongLongStructPubSubType::deleteData( +void FinalULongLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalULongLongStructPubSubType::getKey( +bool FinalULongLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalULongLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalULongLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool FinalULongLongStructPubSubType::getKey( const FinalULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalULongLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalULongLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void FinalULongLongStructPubSubType::register_type_object_representation() FinalFloatStructPubSubType::FinalFloatStructPubSubType() { - setName("FinalFloatStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalFloatStruct::getMaxCdrSerializedSize()); -#else - FinalFloatStruct_max_cdr_typesize; -#endif + set_name("FinalFloatStruct"); + uint32_t type_size = FinalFloatStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalFloatStruct_max_key_cdr_typesize > 16 ? FinalFloatStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalFloatStruct_max_key_cdr_typesize > 16 ? FinalFloatStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalFloatStructPubSubType::~FinalFloatStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalFloatStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool FinalFloatStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalFloatStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool FinalFloatStructPubSubType::deserialize( FinalFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool FinalFloatStructPubSubType::deserialize( return true; } -std::function FinalFloatStructPubSubType::getSerializedSizeProvider( +uint32_t FinalFloatStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalFloatStructPubSubType::createData() + 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* FinalFloatStructPubSubType::create_data() { return reinterpret_cast(new FinalFloatStruct()); } -void FinalFloatStructPubSubType::deleteData( +void FinalFloatStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalFloatStructPubSubType::getKey( +bool FinalFloatStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalFloatStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalFloatStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool FinalFloatStructPubSubType::getKey( const FinalFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalFloatStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalFloatStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void FinalFloatStructPubSubType::register_type_object_representation() FinalDoubleStructPubSubType::FinalDoubleStructPubSubType() { - setName("FinalDoubleStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalDoubleStruct::getMaxCdrSerializedSize()); -#else - FinalDoubleStruct_max_cdr_typesize; -#endif + set_name("FinalDoubleStruct"); + uint32_t type_size = FinalDoubleStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalDoubleStruct_max_key_cdr_typesize > 16 ? FinalDoubleStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalDoubleStruct_max_key_cdr_typesize > 16 ? FinalDoubleStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalDoubleStructPubSubType::~FinalDoubleStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalDoubleStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool FinalDoubleStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalDoubleStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool FinalDoubleStructPubSubType::deserialize( FinalDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool FinalDoubleStructPubSubType::deserialize( return true; } -std::function FinalDoubleStructPubSubType::getSerializedSizeProvider( +uint32_t FinalDoubleStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalDoubleStructPubSubType::createData() + 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* FinalDoubleStructPubSubType::create_data() { return reinterpret_cast(new FinalDoubleStruct()); } -void FinalDoubleStructPubSubType::deleteData( +void FinalDoubleStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalDoubleStructPubSubType::getKey( +bool FinalDoubleStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalDoubleStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalDoubleStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool FinalDoubleStructPubSubType::getKey( const FinalDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalDoubleStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalDoubleStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void FinalDoubleStructPubSubType::register_type_object_representation() FinalLongDoubleStructPubSubType::FinalLongDoubleStructPubSubType() { - setName("FinalLongDoubleStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalLongDoubleStruct::getMaxCdrSerializedSize()); -#else - FinalLongDoubleStruct_max_cdr_typesize; -#endif + set_name("FinalLongDoubleStruct"); + uint32_t type_size = FinalLongDoubleStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalLongDoubleStruct_max_key_cdr_typesize > 16 ? FinalLongDoubleStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalLongDoubleStruct_max_key_cdr_typesize > 16 ? FinalLongDoubleStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalLongDoubleStructPubSubType::~FinalLongDoubleStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalLongDoubleStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool FinalLongDoubleStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalLongDoubleStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool FinalLongDoubleStructPubSubType::deserialize( FinalLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool FinalLongDoubleStructPubSubType::deserialize( return true; } -std::function FinalLongDoubleStructPubSubType::getSerializedSizeProvider( +uint32_t FinalLongDoubleStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalLongDoubleStructPubSubType::createData() + 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* FinalLongDoubleStructPubSubType::create_data() { return reinterpret_cast(new FinalLongDoubleStruct()); } -void FinalLongDoubleStructPubSubType::deleteData( +void FinalLongDoubleStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalLongDoubleStructPubSubType::getKey( +bool FinalLongDoubleStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalLongDoubleStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalLongDoubleStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool FinalLongDoubleStructPubSubType::getKey( const FinalLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalLongDoubleStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalLongDoubleStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void FinalLongDoubleStructPubSubType::register_type_object_representation() FinalBooleanStructPubSubType::FinalBooleanStructPubSubType() { - setName("FinalBooleanStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalBooleanStruct::getMaxCdrSerializedSize()); -#else - FinalBooleanStruct_max_cdr_typesize; -#endif + set_name("FinalBooleanStruct"); + uint32_t type_size = FinalBooleanStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalBooleanStruct_max_key_cdr_typesize > 16 ? FinalBooleanStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalBooleanStruct_max_key_cdr_typesize > 16 ? FinalBooleanStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalBooleanStructPubSubType::~FinalBooleanStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalBooleanStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool FinalBooleanStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalBooleanStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool FinalBooleanStructPubSubType::deserialize( FinalBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool FinalBooleanStructPubSubType::deserialize( return true; } -std::function FinalBooleanStructPubSubType::getSerializedSizeProvider( +uint32_t FinalBooleanStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalBooleanStructPubSubType::createData() + 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* FinalBooleanStructPubSubType::create_data() { return reinterpret_cast(new FinalBooleanStruct()); } -void FinalBooleanStructPubSubType::deleteData( +void FinalBooleanStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalBooleanStructPubSubType::getKey( +bool FinalBooleanStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalBooleanStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalBooleanStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool FinalBooleanStructPubSubType::getKey( const FinalBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalBooleanStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalBooleanStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void FinalBooleanStructPubSubType::register_type_object_representation() FinalOctetStructPubSubType::FinalOctetStructPubSubType() { - setName("FinalOctetStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalOctetStruct::getMaxCdrSerializedSize()); -#else - FinalOctetStruct_max_cdr_typesize; -#endif + set_name("FinalOctetStruct"); + uint32_t type_size = FinalOctetStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalOctetStruct_max_key_cdr_typesize > 16 ? FinalOctetStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalOctetStruct_max_key_cdr_typesize > 16 ? FinalOctetStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalOctetStructPubSubType::~FinalOctetStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalOctetStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool FinalOctetStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalOctetStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool FinalOctetStructPubSubType::deserialize( FinalOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool FinalOctetStructPubSubType::deserialize( return true; } -std::function FinalOctetStructPubSubType::getSerializedSizeProvider( +uint32_t FinalOctetStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalOctetStructPubSubType::createData() + 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* FinalOctetStructPubSubType::create_data() { return reinterpret_cast(new FinalOctetStruct()); } -void FinalOctetStructPubSubType::deleteData( +void FinalOctetStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalOctetStructPubSubType::getKey( +bool FinalOctetStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalOctetStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalOctetStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool FinalOctetStructPubSubType::getKey( const FinalOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalOctetStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalOctetStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void FinalOctetStructPubSubType::register_type_object_representation() FinalCharStructPubSubType::FinalCharStructPubSubType() { - setName("FinalCharStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalCharStruct::getMaxCdrSerializedSize()); -#else - FinalCharStruct_max_cdr_typesize; -#endif + set_name("FinalCharStruct"); + uint32_t type_size = FinalCharStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalCharStruct_max_key_cdr_typesize > 16 ? FinalCharStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalCharStruct_max_key_cdr_typesize > 16 ? FinalCharStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalCharStructPubSubType::~FinalCharStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalCharStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool FinalCharStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalCharStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool FinalCharStructPubSubType::deserialize( FinalCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool FinalCharStructPubSubType::deserialize( return true; } -std::function FinalCharStructPubSubType::getSerializedSizeProvider( +uint32_t FinalCharStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalCharStructPubSubType::createData() + 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* FinalCharStructPubSubType::create_data() { return reinterpret_cast(new FinalCharStruct()); } -void FinalCharStructPubSubType::deleteData( +void FinalCharStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalCharStructPubSubType::getKey( +bool FinalCharStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalCharStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalCharStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool FinalCharStructPubSubType::getKey( const FinalCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalCharStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalCharStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void FinalCharStructPubSubType::register_type_object_representation() FinalWCharStructPubSubType::FinalWCharStructPubSubType() { - setName("FinalWCharStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalWCharStruct::getMaxCdrSerializedSize()); -#else - FinalWCharStruct_max_cdr_typesize; -#endif + set_name("FinalWCharStruct"); + uint32_t type_size = FinalWCharStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalWCharStruct_max_key_cdr_typesize > 16 ? FinalWCharStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalWCharStruct_max_key_cdr_typesize > 16 ? FinalWCharStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalWCharStructPubSubType::~FinalWCharStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalWCharStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool FinalWCharStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalWCharStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool FinalWCharStructPubSubType::deserialize( FinalWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,52 +2277,62 @@ bool FinalWCharStructPubSubType::deserialize( return true; } -std::function FinalWCharStructPubSubType::getSerializedSizeProvider( +uint32_t FinalWCharStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalWCharStructPubSubType::createData() + 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* FinalWCharStructPubSubType::create_data() { return reinterpret_cast(new FinalWCharStruct()); } -void FinalWCharStructPubSubType::deleteData( +void FinalWCharStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalWCharStructPubSubType::getKey( +bool FinalWCharStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalWCharStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalWCharStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2501,35 +2340,27 @@ bool FinalWCharStructPubSubType::getKey( const FinalWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalWCharStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalWCharStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void FinalWCharStructPubSubType::register_type_object_representation() FinalUnionStructPubSubType::FinalUnionStructPubSubType() { - setName("FinalUnionStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalUnionStruct::getMaxCdrSerializedSize()); -#else - FinalUnionStruct_max_cdr_typesize; -#endif + set_name("FinalUnionStruct"); + uint32_t type_size = FinalUnionStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalUnionStruct_max_key_cdr_typesize > 16 ? FinalUnionStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalUnionStruct_max_key_cdr_typesize > 16 ? FinalUnionStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalUnionStructPubSubType::~FinalUnionStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalUnionStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalUnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool FinalUnionStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalUnionStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool FinalUnionStructPubSubType::deserialize( FinalUnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool FinalUnionStructPubSubType::deserialize( return true; } -std::function FinalUnionStructPubSubType::getSerializedSizeProvider( +uint32_t FinalUnionStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalUnionStructPubSubType::createData() + 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* FinalUnionStructPubSubType::create_data() { return reinterpret_cast(new FinalUnionStruct()); } -void FinalUnionStructPubSubType::deleteData( +void FinalUnionStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalUnionStructPubSubType::getKey( +bool FinalUnionStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalUnionStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalUnionStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool FinalUnionStructPubSubType::getKey( const FinalUnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalUnionStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalUnionStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void FinalUnionStructPubSubType::register_type_object_representation() FinalEmptyStructPubSubType::FinalEmptyStructPubSubType() { - setName("FinalEmptyStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalEmptyStruct::getMaxCdrSerializedSize()); -#else - FinalEmptyStruct_max_cdr_typesize; -#endif + set_name("FinalEmptyStruct"); + uint32_t type_size = FinalEmptyStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalEmptyStruct_max_key_cdr_typesize > 16 ? FinalEmptyStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalEmptyStruct_max_key_cdr_typesize > 16 ? FinalEmptyStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalEmptyStructPubSubType::~FinalEmptyStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalEmptyStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool FinalEmptyStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalEmptyStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool FinalEmptyStructPubSubType::deserialize( FinalEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool FinalEmptyStructPubSubType::deserialize( return true; } -std::function FinalEmptyStructPubSubType::getSerializedSizeProvider( +uint32_t FinalEmptyStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalEmptyStructPubSubType::createData() + 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* FinalEmptyStructPubSubType::create_data() { return reinterpret_cast(new FinalEmptyStruct()); } -void FinalEmptyStructPubSubType::deleteData( +void FinalEmptyStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalEmptyStructPubSubType::getKey( +bool FinalEmptyStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalEmptyStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalEmptyStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool FinalEmptyStructPubSubType::getKey( const FinalEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalEmptyStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalEmptyStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void FinalEmptyStructPubSubType::register_type_object_representation() FinalEmptyInheritanceStructPubSubType::FinalEmptyInheritanceStructPubSubType() { - setName("FinalEmptyInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalEmptyInheritanceStruct::getMaxCdrSerializedSize()); -#else - FinalEmptyInheritanceStruct_max_cdr_typesize; -#endif + set_name("FinalEmptyInheritanceStruct"); + uint32_t type_size = FinalEmptyInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalEmptyInheritanceStruct_max_key_cdr_typesize > 16 ? FinalEmptyInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalEmptyInheritanceStruct_max_key_cdr_typesize > 16 ? FinalEmptyInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalEmptyInheritanceStructPubSubType::~FinalEmptyInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalEmptyInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool FinalEmptyInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalEmptyInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool FinalEmptyInheritanceStructPubSubType::deserialize( FinalEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool FinalEmptyInheritanceStructPubSubType::deserialize( return true; } -std::function FinalEmptyInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t FinalEmptyInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalEmptyInheritanceStructPubSubType::createData() + 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* FinalEmptyInheritanceStructPubSubType::create_data() { return reinterpret_cast(new FinalEmptyInheritanceStruct()); } -void FinalEmptyInheritanceStructPubSubType::deleteData( +void FinalEmptyInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalEmptyInheritanceStructPubSubType::getKey( +bool FinalEmptyInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalEmptyInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalEmptyInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool FinalEmptyInheritanceStructPubSubType::getKey( const FinalEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalEmptyInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalEmptyInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void FinalEmptyInheritanceStructPubSubType::register_type_object_representation( FinalInheritanceStructPubSubType::FinalInheritanceStructPubSubType() { - setName("FinalInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalInheritanceStruct::getMaxCdrSerializedSize()); -#else - FinalInheritanceStruct_max_cdr_typesize; -#endif + set_name("FinalInheritanceStruct"); + uint32_t type_size = FinalInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalInheritanceStruct_max_key_cdr_typesize > 16 ? FinalInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalInheritanceStruct_max_key_cdr_typesize > 16 ? FinalInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalInheritanceStructPubSubType::~FinalInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool FinalInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool FinalInheritanceStructPubSubType::deserialize( FinalInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool FinalInheritanceStructPubSubType::deserialize( return true; } -std::function FinalInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t FinalInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalInheritanceStructPubSubType::createData() + 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* FinalInheritanceStructPubSubType::create_data() { return reinterpret_cast(new FinalInheritanceStruct()); } -void FinalInheritanceStructPubSubType::deleteData( +void FinalInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalInheritanceStructPubSubType::getKey( +bool FinalInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool FinalInheritanceStructPubSubType::getKey( const FinalInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void FinalInheritanceStructPubSubType::register_type_object_representation() InheritanceEmptyStructPubSubType::InheritanceEmptyStructPubSubType() { - setName("InheritanceEmptyStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InheritanceEmptyStruct::getMaxCdrSerializedSize()); -#else - InheritanceEmptyStruct_max_cdr_typesize; -#endif + set_name("InheritanceEmptyStruct"); + uint32_t type_size = InheritanceEmptyStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = InheritanceEmptyStruct_max_key_cdr_typesize > 16 ? InheritanceEmptyStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = InheritanceEmptyStruct_max_key_cdr_typesize > 16 ? InheritanceEmptyStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InheritanceEmptyStructPubSubType::~InheritanceEmptyStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InheritanceEmptyStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InheritanceEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool InheritanceEmptyStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InheritanceEmptyStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool InheritanceEmptyStructPubSubType::deserialize( InheritanceEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool InheritanceEmptyStructPubSubType::deserialize( return true; } -std::function InheritanceEmptyStructPubSubType::getSerializedSizeProvider( +uint32_t InheritanceEmptyStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* InheritanceEmptyStructPubSubType::createData() + 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* InheritanceEmptyStructPubSubType::create_data() { return reinterpret_cast(new InheritanceEmptyStruct()); } -void InheritanceEmptyStructPubSubType::deleteData( +void InheritanceEmptyStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InheritanceEmptyStructPubSubType::getKey( +bool InheritanceEmptyStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InheritanceEmptyStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InheritanceEmptyStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool InheritanceEmptyStructPubSubType::getKey( const InheritanceEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InheritanceEmptyStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InheritanceEmptyStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void InheritanceEmptyStructPubSubType::register_type_object_representation() FinalExtensibilityInheritancePubSubType::FinalExtensibilityInheritancePubSubType() { - setName("FinalExtensibilityInheritance"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalExtensibilityInheritance::getMaxCdrSerializedSize()); -#else - FinalExtensibilityInheritance_max_cdr_typesize; -#endif + set_name("FinalExtensibilityInheritance"); + uint32_t type_size = FinalExtensibilityInheritance_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalExtensibilityInheritance_max_key_cdr_typesize > 16 ? FinalExtensibilityInheritance_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalExtensibilityInheritance_max_key_cdr_typesize > 16 ? FinalExtensibilityInheritance_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalExtensibilityInheritancePubSubType::~FinalExtensibilityInheritancePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalExtensibilityInheritancePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalExtensibilityInheritance* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool FinalExtensibilityInheritancePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalExtensibilityInheritancePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool FinalExtensibilityInheritancePubSubType::deserialize( FinalExtensibilityInheritance* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool FinalExtensibilityInheritancePubSubType::deserialize( return true; } -std::function FinalExtensibilityInheritancePubSubType::getSerializedSizeProvider( +uint32_t FinalExtensibilityInheritancePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalExtensibilityInheritancePubSubType::createData() + 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* FinalExtensibilityInheritancePubSubType::create_data() { return reinterpret_cast(new FinalExtensibilityInheritance()); } -void FinalExtensibilityInheritancePubSubType::deleteData( +void FinalExtensibilityInheritancePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalExtensibilityInheritancePubSubType::getKey( +bool FinalExtensibilityInheritancePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalExtensibilityInheritance data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalExtensibilityInheritancePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool FinalExtensibilityInheritancePubSubType::getKey( const FinalExtensibilityInheritance* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalExtensibilityInheritance_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalExtensibilityInheritance_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/finalPubSubTypes.hpp b/test/dds-types-test/finalPubSubTypes.hpp index f0e601fca31..a8786266315 100644 --- a/test/dds-types-test/finalPubSubTypes.hpp +++ b/test/dds-types-test/finalPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated final is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER #ifndef SWIG @@ -88,38 +88,30 @@ class FinalShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -134,10 +126,6 @@ class FinalShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -164,11 +152,12 @@ class FinalShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 2ULL == @@ -234,38 +223,30 @@ class FinalUShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -280,10 +261,6 @@ class FinalUShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -310,11 +287,12 @@ class FinalUShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 2ULL == @@ -380,38 +358,30 @@ class FinalLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -426,10 +396,6 @@ class FinalLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -456,11 +422,12 @@ class FinalLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 4ULL == @@ -526,38 +493,30 @@ class FinalULongStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -572,10 +531,6 @@ class FinalULongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -602,11 +557,12 @@ class FinalULongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 4ULL == @@ -672,38 +628,30 @@ class FinalLongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -718,10 +666,6 @@ class FinalLongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -748,11 +692,12 @@ class FinalLongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 8ULL == @@ -818,38 +763,30 @@ class FinalULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -864,10 +801,6 @@ class FinalULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -894,11 +827,12 @@ class FinalULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 8ULL == @@ -964,38 +898,30 @@ class FinalFloatStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1010,10 +936,6 @@ class FinalFloatStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1040,11 +962,12 @@ class FinalFloatStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 4ULL == @@ -1110,38 +1033,30 @@ class FinalDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1156,10 +1071,6 @@ class FinalDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1186,11 +1097,12 @@ class FinalDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 8ULL == @@ -1256,38 +1168,30 @@ class FinalLongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1302,10 +1206,6 @@ class FinalLongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1332,11 +1232,12 @@ class FinalLongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 16ULL == @@ -1402,38 +1303,30 @@ class FinalBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1448,10 +1341,6 @@ class FinalBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1478,11 +1367,12 @@ class FinalBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 1ULL == @@ -1548,38 +1438,30 @@ class FinalOctetStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1594,10 +1476,6 @@ class FinalOctetStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1624,11 +1502,12 @@ class FinalOctetStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 1ULL == @@ -1694,38 +1573,30 @@ class FinalCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1740,10 +1611,6 @@ class FinalCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1770,11 +1637,12 @@ class FinalCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 1ULL == @@ -1840,38 +1708,30 @@ class FinalWCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1886,10 +1746,6 @@ class FinalWCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1916,11 +1772,12 @@ class FinalWCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 2ULL == @@ -1953,38 +1810,30 @@ class FinalUnionStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1999,10 +1848,6 @@ class FinalUnionStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2023,8 +1868,10 @@ class FinalUnionStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2044,38 +1891,30 @@ class FinalEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2090,10 +1929,6 @@ class FinalEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2120,11 +1955,12 @@ class FinalEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return true; @@ -2153,38 +1989,30 @@ class FinalEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2199,10 +2027,6 @@ class FinalEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2223,8 +2047,10 @@ class FinalEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2244,38 +2070,30 @@ class FinalInheritanceStructPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2290,10 +2108,6 @@ class FinalInheritanceStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2314,8 +2128,10 @@ class FinalInheritanceStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2335,38 +2151,30 @@ class InheritanceEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2381,10 +2189,6 @@ class InheritanceEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2411,11 +2215,12 @@ class InheritanceEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 2ULL == @@ -2481,38 +2286,30 @@ class FinalExtensibilityInheritancePubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2527,10 +2324,6 @@ class FinalExtensibilityInheritancePubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2557,11 +2350,12 @@ class FinalExtensibilityInheritancePubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 8ULL == diff --git a/test/dds-types-test/helpers/basic_inner_typesPubSubTypes.cxx b/test/dds-types-test/helpers/basic_inner_typesPubSubTypes.cxx index cea43fb311e..36136420e93 100644 --- a/test/dds-types-test/helpers/basic_inner_typesPubSubTypes.cxx +++ b/test/dds-types-test/helpers/basic_inner_typesPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; InnerStructureHelperPubSubType::InnerStructureHelperPubSubType() { - setName("InnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InnerStructureHelper::getMaxCdrSerializedSize()); -#else - InnerStructureHelper_max_cdr_typesize; -#endif + set_name("InnerStructureHelper"); + uint32_t type_size = InnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = InnerStructureHelper_max_key_cdr_typesize > 16 ? InnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = InnerStructureHelper_max_key_cdr_typesize > 16 ? InnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InnerStructureHelperPubSubType::~InnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool InnerStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool InnerStructureHelperPubSubType::deserialize( InnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool InnerStructureHelperPubSubType::deserialize( return true; } -std::function InnerStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t InnerStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* InnerStructureHelperPubSubType::createData() +void* InnerStructureHelperPubSubType::create_data() { return reinterpret_cast(new InnerStructureHelper()); } -void InnerStructureHelperPubSubType::deleteData( +void InnerStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InnerStructureHelperPubSubType::getKey( +bool InnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InnerStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool InnerStructureHelperPubSubType::getKey( const InnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InnerStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InnerStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void InnerStructureHelperPubSubType::register_type_object_representation() InnerEmptyStructureHelperPubSubType::InnerEmptyStructureHelperPubSubType() { - setName("InnerEmptyStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InnerEmptyStructureHelper::getMaxCdrSerializedSize()); -#else - InnerEmptyStructureHelper_max_cdr_typesize; -#endif + set_name("InnerEmptyStructureHelper"); + uint32_t type_size = InnerEmptyStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = InnerEmptyStructureHelper_max_key_cdr_typesize > 16 ? InnerEmptyStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = InnerEmptyStructureHelper_max_key_cdr_typesize > 16 ? InnerEmptyStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InnerEmptyStructureHelperPubSubType::~InnerEmptyStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InnerEmptyStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InnerEmptyStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool InnerEmptyStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InnerEmptyStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool InnerEmptyStructureHelperPubSubType::deserialize( InnerEmptyStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool InnerEmptyStructureHelperPubSubType::deserialize( return true; } -std::function InnerEmptyStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t InnerEmptyStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* InnerEmptyStructureHelperPubSubType::createData() +void* InnerEmptyStructureHelperPubSubType::create_data() { return reinterpret_cast(new InnerEmptyStructureHelper()); } -void InnerEmptyStructureHelperPubSubType::deleteData( +void InnerEmptyStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InnerEmptyStructureHelperPubSubType::getKey( +bool InnerEmptyStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InnerEmptyStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InnerEmptyStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool InnerEmptyStructureHelperPubSubType::getKey( const InnerEmptyStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InnerEmptyStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InnerEmptyStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/helpers/basic_inner_typesPubSubTypes.hpp b/test/dds-types-test/helpers/basic_inner_typesPubSubTypes.hpp index a3cb7ac6e95..3a34f042fcc 100644 --- a/test/dds-types-test/helpers/basic_inner_typesPubSubTypes.hpp +++ b/test/dds-types-test/helpers/basic_inner_typesPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "basic_inner_types.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated basic_inner_types is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER typedef int32_t InnerAliasHelper; @@ -55,38 +55,30 @@ class InnerStructureHelperPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class InnerStructureHelperPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class InnerStructureHelperPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class InnerEmptyStructureHelperPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class InnerEmptyStructureHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class InnerEmptyStructureHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/helpers/basic_inner_typesTypeObjectSupport.cxx b/test/dds-types-test/helpers/basic_inner_typesTypeObjectSupport.cxx index 35dbe23e632..f634f343488 100644 --- a/test/dds-types-test/helpers/basic_inner_typesTypeObjectSupport.cxx +++ b/test/dds-types-test/helpers/basic_inner_typesTypeObjectSupport.cxx @@ -647,7 +647,7 @@ void register_InnerBitsetHelper_type_identifier( uint16_t position_a = 0; BitsetMemberFlag flags_a = 0; uint8_t bitcount_a = 3; - TypeKind holder_type_a = TK_BYTE; + TypeKind holder_type_a = TK_UINT8; CommonBitfield common_a = TypeObjectUtils::build_common_bitfield(position_a, flags_a, bitcount_a, holder_type_a); eprosima::fastcdr::optional member_ann_builtin_a; ann_custom_InnerBitsetHelper.reset(); diff --git a/test/dds-types-test/inheritancePubSubTypes.cxx b/test/dds-types-test/inheritancePubSubTypes.cxx index aea4de131a7..3e104853aff 100644 --- a/test/dds-types-test/inheritancePubSubTypes.cxx +++ b/test/dds-types-test/inheritancePubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; InnerStructureHelperChildPubSubType::InnerStructureHelperChildPubSubType() { - setName("InnerStructureHelperChild"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InnerStructureHelperChild::getMaxCdrSerializedSize()); -#else - InnerStructureHelperChild_max_cdr_typesize; -#endif + set_name("InnerStructureHelperChild"); + uint32_t type_size = InnerStructureHelperChild_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = InnerStructureHelperChild_max_key_cdr_typesize > 16 ? InnerStructureHelperChild_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = InnerStructureHelperChild_max_key_cdr_typesize > 16 ? InnerStructureHelperChild_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InnerStructureHelperChildPubSubType::~InnerStructureHelperChildPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InnerStructureHelperChildPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InnerStructureHelperChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool InnerStructureHelperChildPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InnerStructureHelperChildPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool InnerStructureHelperChildPubSubType::deserialize( InnerStructureHelperChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool InnerStructureHelperChildPubSubType::deserialize( return true; } -std::function InnerStructureHelperChildPubSubType::getSerializedSizeProvider( +uint32_t InnerStructureHelperChildPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* InnerStructureHelperChildPubSubType::createData() + 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* InnerStructureHelperChildPubSubType::create_data() { return reinterpret_cast(new InnerStructureHelperChild()); } -void InnerStructureHelperChildPubSubType::deleteData( +void InnerStructureHelperChildPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InnerStructureHelperChildPubSubType::getKey( +bool InnerStructureHelperChildPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InnerStructureHelperChild data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InnerStructureHelperChildPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool InnerStructureHelperChildPubSubType::getKey( const InnerStructureHelperChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InnerStructureHelperChild_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InnerStructureHelperChild_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void InnerStructureHelperChildPubSubType::register_type_object_representation() InnerStructureHelperChildChildPubSubType::InnerStructureHelperChildChildPubSubType() { - setName("InnerStructureHelperChildChild"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InnerStructureHelperChildChild::getMaxCdrSerializedSize()); -#else - InnerStructureHelperChildChild_max_cdr_typesize; -#endif + set_name("InnerStructureHelperChildChild"); + uint32_t type_size = InnerStructureHelperChildChild_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = InnerStructureHelperChildChild_max_key_cdr_typesize > 16 ? InnerStructureHelperChildChild_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = InnerStructureHelperChildChild_max_key_cdr_typesize > 16 ? InnerStructureHelperChildChild_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InnerStructureHelperChildChildPubSubType::~InnerStructureHelperChildChildPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InnerStructureHelperChildChildPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InnerStructureHelperChildChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool InnerStructureHelperChildChildPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InnerStructureHelperChildChildPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool InnerStructureHelperChildChildPubSubType::deserialize( InnerStructureHelperChildChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool InnerStructureHelperChildChildPubSubType::deserialize( return true; } -std::function InnerStructureHelperChildChildPubSubType::getSerializedSizeProvider( +uint32_t InnerStructureHelperChildChildPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* InnerStructureHelperChildChildPubSubType::createData() + 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* InnerStructureHelperChildChildPubSubType::create_data() { return reinterpret_cast(new InnerStructureHelperChildChild()); } -void InnerStructureHelperChildChildPubSubType::deleteData( +void InnerStructureHelperChildChildPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InnerStructureHelperChildChildPubSubType::getKey( +bool InnerStructureHelperChildChildPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InnerStructureHelperChildChild data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InnerStructureHelperChildChildPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool InnerStructureHelperChildChildPubSubType::getKey( const InnerStructureHelperChildChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InnerStructureHelperChildChild_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InnerStructureHelperChildChild_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void InnerStructureHelperChildChildPubSubType::register_type_object_representati InnerStructureHelperEmptyChildPubSubType::InnerStructureHelperEmptyChildPubSubType() { - setName("InnerStructureHelperEmptyChild"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InnerStructureHelperEmptyChild::getMaxCdrSerializedSize()); -#else - InnerStructureHelperEmptyChild_max_cdr_typesize; -#endif + set_name("InnerStructureHelperEmptyChild"); + uint32_t type_size = InnerStructureHelperEmptyChild_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = InnerStructureHelperEmptyChild_max_key_cdr_typesize > 16 ? InnerStructureHelperEmptyChild_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = InnerStructureHelperEmptyChild_max_key_cdr_typesize > 16 ? InnerStructureHelperEmptyChild_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InnerStructureHelperEmptyChildPubSubType::~InnerStructureHelperEmptyChildPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InnerStructureHelperEmptyChildPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InnerStructureHelperEmptyChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool InnerStructureHelperEmptyChildPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InnerStructureHelperEmptyChildPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool InnerStructureHelperEmptyChildPubSubType::deserialize( InnerStructureHelperEmptyChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool InnerStructureHelperEmptyChildPubSubType::deserialize( return true; } -std::function InnerStructureHelperEmptyChildPubSubType::getSerializedSizeProvider( +uint32_t InnerStructureHelperEmptyChildPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* InnerStructureHelperEmptyChildPubSubType::createData() + 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* InnerStructureHelperEmptyChildPubSubType::create_data() { return reinterpret_cast(new InnerStructureHelperEmptyChild()); } -void InnerStructureHelperEmptyChildPubSubType::deleteData( +void InnerStructureHelperEmptyChildPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InnerStructureHelperEmptyChildPubSubType::getKey( +bool InnerStructureHelperEmptyChildPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InnerStructureHelperEmptyChild data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InnerStructureHelperEmptyChildPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool InnerStructureHelperEmptyChildPubSubType::getKey( const InnerStructureHelperEmptyChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InnerStructureHelperEmptyChild_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InnerStructureHelperEmptyChild_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void InnerStructureHelperEmptyChildPubSubType::register_type_object_representati InnerStructureHelperEmptyChildChildPubSubType::InnerStructureHelperEmptyChildChildPubSubType() { - setName("InnerStructureHelperEmptyChildChild"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InnerStructureHelperEmptyChildChild::getMaxCdrSerializedSize()); -#else - InnerStructureHelperEmptyChildChild_max_cdr_typesize; -#endif + set_name("InnerStructureHelperEmptyChildChild"); + uint32_t type_size = InnerStructureHelperEmptyChildChild_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = InnerStructureHelperEmptyChildChild_max_key_cdr_typesize > 16 ? InnerStructureHelperEmptyChildChild_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = InnerStructureHelperEmptyChildChild_max_key_cdr_typesize > 16 ? InnerStructureHelperEmptyChildChild_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InnerStructureHelperEmptyChildChildPubSubType::~InnerStructureHelperEmptyChildChildPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InnerStructureHelperEmptyChildChildPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InnerStructureHelperEmptyChildChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool InnerStructureHelperEmptyChildChildPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InnerStructureHelperEmptyChildChildPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool InnerStructureHelperEmptyChildChildPubSubType::deserialize( InnerStructureHelperEmptyChildChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool InnerStructureHelperEmptyChildChildPubSubType::deserialize( return true; } -std::function InnerStructureHelperEmptyChildChildPubSubType::getSerializedSizeProvider( +uint32_t InnerStructureHelperEmptyChildChildPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* InnerStructureHelperEmptyChildChildPubSubType::createData() + 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* InnerStructureHelperEmptyChildChildPubSubType::create_data() { return reinterpret_cast(new InnerStructureHelperEmptyChildChild()); } -void InnerStructureHelperEmptyChildChildPubSubType::deleteData( +void InnerStructureHelperEmptyChildChildPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InnerStructureHelperEmptyChildChildPubSubType::getKey( +bool InnerStructureHelperEmptyChildChildPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InnerStructureHelperEmptyChildChild data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InnerStructureHelperEmptyChildChildPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool InnerStructureHelperEmptyChildChildPubSubType::getKey( const InnerStructureHelperEmptyChildChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InnerStructureHelperEmptyChildChild_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InnerStructureHelperEmptyChildChild_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void InnerStructureHelperEmptyChildChildPubSubType::register_type_object_represe InnerEmptyStructureHelperChildPubSubType::InnerEmptyStructureHelperChildPubSubType() { - setName("InnerEmptyStructureHelperChild"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InnerEmptyStructureHelperChild::getMaxCdrSerializedSize()); -#else - InnerEmptyStructureHelperChild_max_cdr_typesize; -#endif + set_name("InnerEmptyStructureHelperChild"); + uint32_t type_size = InnerEmptyStructureHelperChild_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = InnerEmptyStructureHelperChild_max_key_cdr_typesize > 16 ? InnerEmptyStructureHelperChild_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = InnerEmptyStructureHelperChild_max_key_cdr_typesize > 16 ? InnerEmptyStructureHelperChild_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InnerEmptyStructureHelperChildPubSubType::~InnerEmptyStructureHelperChildPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InnerEmptyStructureHelperChildPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InnerEmptyStructureHelperChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool InnerEmptyStructureHelperChildPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InnerEmptyStructureHelperChildPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool InnerEmptyStructureHelperChildPubSubType::deserialize( InnerEmptyStructureHelperChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool InnerEmptyStructureHelperChildPubSubType::deserialize( return true; } -std::function InnerEmptyStructureHelperChildPubSubType::getSerializedSizeProvider( +uint32_t InnerEmptyStructureHelperChildPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* InnerEmptyStructureHelperChildPubSubType::createData() + 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* InnerEmptyStructureHelperChildPubSubType::create_data() { return reinterpret_cast(new InnerEmptyStructureHelperChild()); } -void InnerEmptyStructureHelperChildPubSubType::deleteData( +void InnerEmptyStructureHelperChildPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InnerEmptyStructureHelperChildPubSubType::getKey( +bool InnerEmptyStructureHelperChildPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InnerEmptyStructureHelperChild data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InnerEmptyStructureHelperChildPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool InnerEmptyStructureHelperChildPubSubType::getKey( const InnerEmptyStructureHelperChild* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InnerEmptyStructureHelperChild_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InnerEmptyStructureHelperChild_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void InnerEmptyStructureHelperChildPubSubType::register_type_object_representati StructAliasInheritanceStructPubSubType::StructAliasInheritanceStructPubSubType() { - setName("StructAliasInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructAliasInheritanceStruct::getMaxCdrSerializedSize()); -#else - StructAliasInheritanceStruct_max_cdr_typesize; -#endif + set_name("StructAliasInheritanceStruct"); + uint32_t type_size = StructAliasInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructAliasInheritanceStruct_max_key_cdr_typesize > 16 ? StructAliasInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructAliasInheritanceStruct_max_key_cdr_typesize > 16 ? StructAliasInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructAliasInheritanceStructPubSubType::~StructAliasInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructAliasInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructAliasInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool StructAliasInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructAliasInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool StructAliasInheritanceStructPubSubType::deserialize( StructAliasInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool StructAliasInheritanceStructPubSubType::deserialize( return true; } -std::function StructAliasInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t StructAliasInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructAliasInheritanceStructPubSubType::createData() + 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* StructAliasInheritanceStructPubSubType::create_data() { return reinterpret_cast(new StructAliasInheritanceStruct()); } -void StructAliasInheritanceStructPubSubType::deleteData( +void StructAliasInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructAliasInheritanceStructPubSubType::getKey( +bool StructAliasInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructAliasInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructAliasInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool StructAliasInheritanceStructPubSubType::getKey( const StructAliasInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructAliasInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructAliasInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void StructAliasInheritanceStructPubSubType::register_type_object_representation StructuresInheritanceStructPubSubType::StructuresInheritanceStructPubSubType() { - setName("StructuresInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructuresInheritanceStruct::getMaxCdrSerializedSize()); -#else - StructuresInheritanceStruct_max_cdr_typesize; -#endif + set_name("StructuresInheritanceStruct"); + uint32_t type_size = StructuresInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructuresInheritanceStruct_max_key_cdr_typesize > 16 ? StructuresInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructuresInheritanceStruct_max_key_cdr_typesize > 16 ? StructuresInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructuresInheritanceStructPubSubType::~StructuresInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructuresInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructuresInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool StructuresInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructuresInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool StructuresInheritanceStructPubSubType::deserialize( StructuresInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool StructuresInheritanceStructPubSubType::deserialize( return true; } -std::function StructuresInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t StructuresInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructuresInheritanceStructPubSubType::createData() + 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* StructuresInheritanceStructPubSubType::create_data() { return reinterpret_cast(new StructuresInheritanceStruct()); } -void StructuresInheritanceStructPubSubType::deleteData( +void StructuresInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructuresInheritanceStructPubSubType::getKey( +bool StructuresInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructuresInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructuresInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool StructuresInheritanceStructPubSubType::getKey( const StructuresInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructuresInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructuresInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1387,49 +1296,42 @@ void StructuresInheritanceStructPubSubType::register_type_object_representation( BitsetsChildInheritanceStructPubSubType::BitsetsChildInheritanceStructPubSubType() { - setName("BitsetsChildInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BitsetsChildInheritanceStruct::getMaxCdrSerializedSize()); -#else - BitsetsChildInheritanceStruct_max_cdr_typesize; -#endif + set_name("BitsetsChildInheritanceStruct"); + uint32_t type_size = BitsetsChildInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BitsetsChildInheritanceStruct_max_key_cdr_typesize > 16 ? BitsetsChildInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BitsetsChildInheritanceStruct_max_key_cdr_typesize > 16 ? BitsetsChildInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BitsetsChildInheritanceStructPubSubType::~BitsetsChildInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BitsetsChildInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BitsetsChildInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1444,16 +1346,12 @@ bool BitsetsChildInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BitsetsChildInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1462,18 +1360,14 @@ bool BitsetsChildInheritanceStructPubSubType::deserialize( BitsetsChildInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1486,52 +1380,62 @@ bool BitsetsChildInheritanceStructPubSubType::deserialize( return true; } -std::function BitsetsChildInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t BitsetsChildInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* BitsetsChildInheritanceStructPubSubType::createData() + 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* BitsetsChildInheritanceStructPubSubType::create_data() { return reinterpret_cast(new BitsetsChildInheritanceStruct()); } -void BitsetsChildInheritanceStructPubSubType::deleteData( +void BitsetsChildInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BitsetsChildInheritanceStructPubSubType::getKey( +bool BitsetsChildInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BitsetsChildInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BitsetsChildInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1539,35 +1443,27 @@ bool BitsetsChildInheritanceStructPubSubType::getKey( const BitsetsChildInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BitsetsChildInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BitsetsChildInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/inheritancePubSubTypes.hpp b/test/dds-types-test/inheritancePubSubTypes.hpp index d72a0642be2..5261daeadca 100644 --- a/test/dds-types-test/inheritancePubSubTypes.hpp +++ b/test/dds-types-test/inheritancePubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated inheritance is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class InnerStructureHelperChildPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class InnerStructureHelperChildPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class InnerStructureHelperChildPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class InnerStructureHelperChildChildPubSubType : public eprosima::fastdds::dds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class InnerStructureHelperChildChildPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class InnerStructureHelperChildChildPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -237,38 +217,30 @@ class InnerStructureHelperEmptyChildPubSubType : public eprosima::fastdds::dds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -283,10 +255,6 @@ class InnerStructureHelperEmptyChildPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,8 +275,10 @@ class InnerStructureHelperEmptyChildPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -328,38 +298,30 @@ class InnerStructureHelperEmptyChildChildPubSubType : public eprosima::fastdds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -374,10 +336,6 @@ class InnerStructureHelperEmptyChildChildPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -398,8 +356,10 @@ class InnerStructureHelperEmptyChildChildPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -419,38 +379,30 @@ class InnerEmptyStructureHelperChildPubSubType : public eprosima::fastdds::dds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -465,10 +417,6 @@ class InnerEmptyStructureHelperChildPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -489,8 +437,10 @@ class InnerEmptyStructureHelperChildPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -510,38 +460,30 @@ class StructAliasInheritanceStructPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -556,10 +498,6 @@ class StructAliasInheritanceStructPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -580,8 +518,10 @@ class StructAliasInheritanceStructPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -601,38 +541,30 @@ class StructuresInheritanceStructPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -647,10 +579,6 @@ class StructuresInheritanceStructPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -671,8 +599,10 @@ class StructuresInheritanceStructPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -695,38 +625,30 @@ class BitsetsChildInheritanceStructPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -741,10 +663,6 @@ class BitsetsChildInheritanceStructPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -765,8 +683,10 @@ class BitsetsChildInheritanceStructPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/inheritanceTypeObjectSupport.cxx b/test/dds-types-test/inheritanceTypeObjectSupport.cxx index 9dbab17bc21..f427506e27e 100644 --- a/test/dds-types-test/inheritanceTypeObjectSupport.cxx +++ b/test/dds-types-test/inheritanceTypeObjectSupport.cxx @@ -796,7 +796,7 @@ void register_InnerBitsetHelperChild_type_identifier( uint16_t position_a = 0; BitsetMemberFlag flags_a = 0; uint8_t bitcount_a = 3; - TypeKind holder_type_a = TK_BYTE; + TypeKind holder_type_a = TK_UINT8; CommonBitfield common_a = TypeObjectUtils::build_common_bitfield(position_a, flags_a, bitcount_a, holder_type_a); eprosima::fastcdr::optional member_ann_builtin_a; ann_custom_InnerBitsetHelperChild.reset(); @@ -886,7 +886,7 @@ void register_InnerBitsetHelperChild_type_identifier( uint16_t position_a = 0; BitsetMemberFlag flags_a = 0; uint8_t bitcount_a = 3; - TypeKind holder_type_a = TK_BYTE; + TypeKind holder_type_a = TK_UINT8; CommonBitfield common_a = TypeObjectUtils::build_common_bitfield(position_a, flags_a, bitcount_a, holder_type_a); eprosima::fastcdr::optional member_ann_builtin_a; ann_custom_InnerBitsetHelperChildChild.reset(); @@ -989,7 +989,7 @@ void register_InnerBitsetHelperChild_type_identifier( uint16_t position_a = 0; BitsetMemberFlag flags_a = 0; uint8_t bitcount_a = 3; - TypeKind holder_type_a = TK_BYTE; + TypeKind holder_type_a = TK_UINT8; CommonBitfield common_a = TypeObjectUtils::build_common_bitfield(position_a, flags_a, bitcount_a, holder_type_a); eprosima::fastcdr::optional member_ann_builtin_a; ann_custom_BitsetAliasInheritanceBitset.reset(); diff --git a/test/dds-types-test/keyPubSubTypes.cxx b/test/dds-types-test/keyPubSubTypes.cxx index a625d907e39..1d0ca1670ae 100644 --- a/test/dds-types-test/keyPubSubTypes.cxx +++ b/test/dds-types-test/keyPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; KeyedShortStructPubSubType::KeyedShortStructPubSubType() { - setName("KeyedShortStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedShortStruct::getMaxCdrSerializedSize()); -#else - KeyedShortStruct_max_cdr_typesize; -#endif + set_name("KeyedShortStruct"); + uint32_t type_size = KeyedShortStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedShortStruct_max_key_cdr_typesize > 16 ? KeyedShortStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedShortStruct_max_key_cdr_typesize > 16 ? KeyedShortStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedShortStructPubSubType::~KeyedShortStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedShortStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool KeyedShortStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedShortStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool KeyedShortStructPubSubType::deserialize( KeyedShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool KeyedShortStructPubSubType::deserialize( return true; } -std::function KeyedShortStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedShortStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedShortStructPubSubType::createData() + 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* KeyedShortStructPubSubType::create_data() { return reinterpret_cast(new KeyedShortStruct()); } -void KeyedShortStructPubSubType::deleteData( +void KeyedShortStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedShortStructPubSubType::getKey( +bool KeyedShortStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedShortStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedShortStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool KeyedShortStructPubSubType::getKey( const KeyedShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedShortStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedShortStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void KeyedShortStructPubSubType::register_type_object_representation() KeyedUShortStructPubSubType::KeyedUShortStructPubSubType() { - setName("KeyedUShortStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedUShortStruct::getMaxCdrSerializedSize()); -#else - KeyedUShortStruct_max_cdr_typesize; -#endif + set_name("KeyedUShortStruct"); + uint32_t type_size = KeyedUShortStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedUShortStruct_max_key_cdr_typesize > 16 ? KeyedUShortStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedUShortStruct_max_key_cdr_typesize > 16 ? KeyedUShortStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedUShortStructPubSubType::~KeyedUShortStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedUShortStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool KeyedUShortStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedUShortStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool KeyedUShortStructPubSubType::deserialize( KeyedUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool KeyedUShortStructPubSubType::deserialize( return true; } -std::function KeyedUShortStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedUShortStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedUShortStructPubSubType::createData() + 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* KeyedUShortStructPubSubType::create_data() { return reinterpret_cast(new KeyedUShortStruct()); } -void KeyedUShortStructPubSubType::deleteData( +void KeyedUShortStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedUShortStructPubSubType::getKey( +bool KeyedUShortStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedUShortStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedUShortStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool KeyedUShortStructPubSubType::getKey( const KeyedUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedUShortStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedUShortStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void KeyedUShortStructPubSubType::register_type_object_representation() KeyedLongStructPubSubType::KeyedLongStructPubSubType() { - setName("KeyedLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedLongStruct::getMaxCdrSerializedSize()); -#else - KeyedLongStruct_max_cdr_typesize; -#endif + set_name("KeyedLongStruct"); + uint32_t type_size = KeyedLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedLongStruct_max_key_cdr_typesize > 16 ? KeyedLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedLongStruct_max_key_cdr_typesize > 16 ? KeyedLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedLongStructPubSubType::~KeyedLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool KeyedLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool KeyedLongStructPubSubType::deserialize( KeyedLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool KeyedLongStructPubSubType::deserialize( return true; } -std::function KeyedLongStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedLongStructPubSubType::createData() + 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* KeyedLongStructPubSubType::create_data() { return reinterpret_cast(new KeyedLongStruct()); } -void KeyedLongStructPubSubType::deleteData( +void KeyedLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedLongStructPubSubType::getKey( +bool KeyedLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool KeyedLongStructPubSubType::getKey( const KeyedLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void KeyedLongStructPubSubType::register_type_object_representation() KeyedULongStructPubSubType::KeyedULongStructPubSubType() { - setName("KeyedULongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedULongStruct::getMaxCdrSerializedSize()); -#else - KeyedULongStruct_max_cdr_typesize; -#endif + set_name("KeyedULongStruct"); + uint32_t type_size = KeyedULongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedULongStruct_max_key_cdr_typesize > 16 ? KeyedULongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedULongStruct_max_key_cdr_typesize > 16 ? KeyedULongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedULongStructPubSubType::~KeyedULongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedULongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool KeyedULongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedULongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool KeyedULongStructPubSubType::deserialize( KeyedULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool KeyedULongStructPubSubType::deserialize( return true; } -std::function KeyedULongStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedULongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedULongStructPubSubType::createData() + 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* KeyedULongStructPubSubType::create_data() { return reinterpret_cast(new KeyedULongStruct()); } -void KeyedULongStructPubSubType::deleteData( +void KeyedULongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedULongStructPubSubType::getKey( +bool KeyedULongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedULongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedULongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool KeyedULongStructPubSubType::getKey( const KeyedULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedULongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedULongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void KeyedULongStructPubSubType::register_type_object_representation() KeyedLongLongStructPubSubType::KeyedLongLongStructPubSubType() { - setName("KeyedLongLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedLongLongStruct::getMaxCdrSerializedSize()); -#else - KeyedLongLongStruct_max_cdr_typesize; -#endif + set_name("KeyedLongLongStruct"); + uint32_t type_size = KeyedLongLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedLongLongStruct_max_key_cdr_typesize > 16 ? KeyedLongLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedLongLongStruct_max_key_cdr_typesize > 16 ? KeyedLongLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedLongLongStructPubSubType::~KeyedLongLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedLongLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool KeyedLongLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedLongLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool KeyedLongLongStructPubSubType::deserialize( KeyedLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool KeyedLongLongStructPubSubType::deserialize( return true; } -std::function KeyedLongLongStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedLongLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedLongLongStructPubSubType::createData() + 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* KeyedLongLongStructPubSubType::create_data() { return reinterpret_cast(new KeyedLongLongStruct()); } -void KeyedLongLongStructPubSubType::deleteData( +void KeyedLongLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedLongLongStructPubSubType::getKey( +bool KeyedLongLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedLongLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedLongLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool KeyedLongLongStructPubSubType::getKey( const KeyedLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedLongLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedLongLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void KeyedLongLongStructPubSubType::register_type_object_representation() KeyedULongLongStructPubSubType::KeyedULongLongStructPubSubType() { - setName("KeyedULongLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedULongLongStruct::getMaxCdrSerializedSize()); -#else - KeyedULongLongStruct_max_cdr_typesize; -#endif + set_name("KeyedULongLongStruct"); + uint32_t type_size = KeyedULongLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedULongLongStruct_max_key_cdr_typesize > 16 ? KeyedULongLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedULongLongStruct_max_key_cdr_typesize > 16 ? KeyedULongLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedULongLongStructPubSubType::~KeyedULongLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedULongLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool KeyedULongLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedULongLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool KeyedULongLongStructPubSubType::deserialize( KeyedULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool KeyedULongLongStructPubSubType::deserialize( return true; } -std::function KeyedULongLongStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedULongLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedULongLongStructPubSubType::createData() + 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* KeyedULongLongStructPubSubType::create_data() { return reinterpret_cast(new KeyedULongLongStruct()); } -void KeyedULongLongStructPubSubType::deleteData( +void KeyedULongLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedULongLongStructPubSubType::getKey( +bool KeyedULongLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedULongLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedULongLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool KeyedULongLongStructPubSubType::getKey( const KeyedULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedULongLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedULongLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void KeyedULongLongStructPubSubType::register_type_object_representation() KeyedFloatStructPubSubType::KeyedFloatStructPubSubType() { - setName("KeyedFloatStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedFloatStruct::getMaxCdrSerializedSize()); -#else - KeyedFloatStruct_max_cdr_typesize; -#endif + set_name("KeyedFloatStruct"); + uint32_t type_size = KeyedFloatStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedFloatStruct_max_key_cdr_typesize > 16 ? KeyedFloatStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedFloatStruct_max_key_cdr_typesize > 16 ? KeyedFloatStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedFloatStructPubSubType::~KeyedFloatStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedFloatStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool KeyedFloatStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedFloatStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool KeyedFloatStructPubSubType::deserialize( KeyedFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool KeyedFloatStructPubSubType::deserialize( return true; } -std::function KeyedFloatStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedFloatStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedFloatStructPubSubType::createData() + 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* KeyedFloatStructPubSubType::create_data() { return reinterpret_cast(new KeyedFloatStruct()); } -void KeyedFloatStructPubSubType::deleteData( +void KeyedFloatStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedFloatStructPubSubType::getKey( +bool KeyedFloatStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedFloatStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedFloatStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool KeyedFloatStructPubSubType::getKey( const KeyedFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedFloatStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedFloatStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void KeyedFloatStructPubSubType::register_type_object_representation() KeyedDoubleStructPubSubType::KeyedDoubleStructPubSubType() { - setName("KeyedDoubleStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedDoubleStruct::getMaxCdrSerializedSize()); -#else - KeyedDoubleStruct_max_cdr_typesize; -#endif + set_name("KeyedDoubleStruct"); + uint32_t type_size = KeyedDoubleStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedDoubleStruct_max_key_cdr_typesize > 16 ? KeyedDoubleStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedDoubleStruct_max_key_cdr_typesize > 16 ? KeyedDoubleStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedDoubleStructPubSubType::~KeyedDoubleStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedDoubleStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool KeyedDoubleStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedDoubleStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool KeyedDoubleStructPubSubType::deserialize( KeyedDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool KeyedDoubleStructPubSubType::deserialize( return true; } -std::function KeyedDoubleStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedDoubleStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedDoubleStructPubSubType::createData() + 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* KeyedDoubleStructPubSubType::create_data() { return reinterpret_cast(new KeyedDoubleStruct()); } -void KeyedDoubleStructPubSubType::deleteData( +void KeyedDoubleStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedDoubleStructPubSubType::getKey( +bool KeyedDoubleStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedDoubleStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedDoubleStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool KeyedDoubleStructPubSubType::getKey( const KeyedDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedDoubleStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedDoubleStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void KeyedDoubleStructPubSubType::register_type_object_representation() KeyedLongDoubleStructPubSubType::KeyedLongDoubleStructPubSubType() { - setName("KeyedLongDoubleStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedLongDoubleStruct::getMaxCdrSerializedSize()); -#else - KeyedLongDoubleStruct_max_cdr_typesize; -#endif + set_name("KeyedLongDoubleStruct"); + uint32_t type_size = KeyedLongDoubleStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedLongDoubleStruct_max_key_cdr_typesize > 16 ? KeyedLongDoubleStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedLongDoubleStruct_max_key_cdr_typesize > 16 ? KeyedLongDoubleStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedLongDoubleStructPubSubType::~KeyedLongDoubleStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedLongDoubleStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool KeyedLongDoubleStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedLongDoubleStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool KeyedLongDoubleStructPubSubType::deserialize( KeyedLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool KeyedLongDoubleStructPubSubType::deserialize( return true; } -std::function KeyedLongDoubleStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedLongDoubleStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedLongDoubleStructPubSubType::createData() + 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* KeyedLongDoubleStructPubSubType::create_data() { return reinterpret_cast(new KeyedLongDoubleStruct()); } -void KeyedLongDoubleStructPubSubType::deleteData( +void KeyedLongDoubleStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedLongDoubleStructPubSubType::getKey( +bool KeyedLongDoubleStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedLongDoubleStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedLongDoubleStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool KeyedLongDoubleStructPubSubType::getKey( const KeyedLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedLongDoubleStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedLongDoubleStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void KeyedLongDoubleStructPubSubType::register_type_object_representation() KeyedBooleanStructPubSubType::KeyedBooleanStructPubSubType() { - setName("KeyedBooleanStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedBooleanStruct::getMaxCdrSerializedSize()); -#else - KeyedBooleanStruct_max_cdr_typesize; -#endif + set_name("KeyedBooleanStruct"); + uint32_t type_size = KeyedBooleanStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedBooleanStruct_max_key_cdr_typesize > 16 ? KeyedBooleanStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedBooleanStruct_max_key_cdr_typesize > 16 ? KeyedBooleanStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedBooleanStructPubSubType::~KeyedBooleanStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedBooleanStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool KeyedBooleanStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedBooleanStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool KeyedBooleanStructPubSubType::deserialize( KeyedBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool KeyedBooleanStructPubSubType::deserialize( return true; } -std::function KeyedBooleanStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedBooleanStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedBooleanStructPubSubType::createData() + 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* KeyedBooleanStructPubSubType::create_data() { return reinterpret_cast(new KeyedBooleanStruct()); } -void KeyedBooleanStructPubSubType::deleteData( +void KeyedBooleanStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedBooleanStructPubSubType::getKey( +bool KeyedBooleanStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedBooleanStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedBooleanStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool KeyedBooleanStructPubSubType::getKey( const KeyedBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedBooleanStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedBooleanStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void KeyedBooleanStructPubSubType::register_type_object_representation() KeyedOctetStructPubSubType::KeyedOctetStructPubSubType() { - setName("KeyedOctetStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedOctetStruct::getMaxCdrSerializedSize()); -#else - KeyedOctetStruct_max_cdr_typesize; -#endif + set_name("KeyedOctetStruct"); + uint32_t type_size = KeyedOctetStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedOctetStruct_max_key_cdr_typesize > 16 ? KeyedOctetStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedOctetStruct_max_key_cdr_typesize > 16 ? KeyedOctetStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedOctetStructPubSubType::~KeyedOctetStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedOctetStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool KeyedOctetStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedOctetStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool KeyedOctetStructPubSubType::deserialize( KeyedOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool KeyedOctetStructPubSubType::deserialize( return true; } -std::function KeyedOctetStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedOctetStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedOctetStructPubSubType::createData() + 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* KeyedOctetStructPubSubType::create_data() { return reinterpret_cast(new KeyedOctetStruct()); } -void KeyedOctetStructPubSubType::deleteData( +void KeyedOctetStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedOctetStructPubSubType::getKey( +bool KeyedOctetStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedOctetStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedOctetStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool KeyedOctetStructPubSubType::getKey( const KeyedOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedOctetStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedOctetStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void KeyedOctetStructPubSubType::register_type_object_representation() KeyedCharStructPubSubType::KeyedCharStructPubSubType() { - setName("KeyedCharStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedCharStruct::getMaxCdrSerializedSize()); -#else - KeyedCharStruct_max_cdr_typesize; -#endif + set_name("KeyedCharStruct"); + uint32_t type_size = KeyedCharStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedCharStruct_max_key_cdr_typesize > 16 ? KeyedCharStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedCharStruct_max_key_cdr_typesize > 16 ? KeyedCharStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedCharStructPubSubType::~KeyedCharStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedCharStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool KeyedCharStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedCharStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool KeyedCharStructPubSubType::deserialize( KeyedCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool KeyedCharStructPubSubType::deserialize( return true; } -std::function KeyedCharStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedCharStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedCharStructPubSubType::createData() + 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* KeyedCharStructPubSubType::create_data() { return reinterpret_cast(new KeyedCharStruct()); } -void KeyedCharStructPubSubType::deleteData( +void KeyedCharStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedCharStructPubSubType::getKey( +bool KeyedCharStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedCharStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedCharStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool KeyedCharStructPubSubType::getKey( const KeyedCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedCharStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedCharStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void KeyedCharStructPubSubType::register_type_object_representation() KeyedWCharStructPubSubType::KeyedWCharStructPubSubType() { - setName("KeyedWCharStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedWCharStruct::getMaxCdrSerializedSize()); -#else - KeyedWCharStruct_max_cdr_typesize; -#endif + set_name("KeyedWCharStruct"); + uint32_t type_size = KeyedWCharStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedWCharStruct_max_key_cdr_typesize > 16 ? KeyedWCharStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedWCharStruct_max_key_cdr_typesize > 16 ? KeyedWCharStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedWCharStructPubSubType::~KeyedWCharStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedWCharStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool KeyedWCharStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedWCharStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool KeyedWCharStructPubSubType::deserialize( KeyedWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,52 +2277,62 @@ bool KeyedWCharStructPubSubType::deserialize( return true; } -std::function KeyedWCharStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedWCharStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedWCharStructPubSubType::createData() + 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* KeyedWCharStructPubSubType::create_data() { return reinterpret_cast(new KeyedWCharStruct()); } -void KeyedWCharStructPubSubType::deleteData( +void KeyedWCharStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedWCharStructPubSubType::getKey( +bool KeyedWCharStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedWCharStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedWCharStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2501,35 +2340,27 @@ bool KeyedWCharStructPubSubType::getKey( const KeyedWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedWCharStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedWCharStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void KeyedWCharStructPubSubType::register_type_object_representation() KeyedEmptyStructPubSubType::KeyedEmptyStructPubSubType() { - setName("KeyedEmptyStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedEmptyStruct::getMaxCdrSerializedSize()); -#else - KeyedEmptyStruct_max_cdr_typesize; -#endif + set_name("KeyedEmptyStruct"); + uint32_t type_size = KeyedEmptyStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedEmptyStruct_max_key_cdr_typesize > 16 ? KeyedEmptyStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedEmptyStruct_max_key_cdr_typesize > 16 ? KeyedEmptyStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedEmptyStructPubSubType::~KeyedEmptyStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedEmptyStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool KeyedEmptyStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedEmptyStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool KeyedEmptyStructPubSubType::deserialize( KeyedEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool KeyedEmptyStructPubSubType::deserialize( return true; } -std::function KeyedEmptyStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedEmptyStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedEmptyStructPubSubType::createData() + 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* KeyedEmptyStructPubSubType::create_data() { return reinterpret_cast(new KeyedEmptyStruct()); } -void KeyedEmptyStructPubSubType::deleteData( +void KeyedEmptyStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedEmptyStructPubSubType::getKey( +bool KeyedEmptyStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedEmptyStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedEmptyStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool KeyedEmptyStructPubSubType::getKey( const KeyedEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedEmptyStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedEmptyStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void KeyedEmptyStructPubSubType::register_type_object_representation() KeyedEmptyInheritanceStructPubSubType::KeyedEmptyInheritanceStructPubSubType() { - setName("KeyedEmptyInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedEmptyInheritanceStruct::getMaxCdrSerializedSize()); -#else - KeyedEmptyInheritanceStruct_max_cdr_typesize; -#endif + set_name("KeyedEmptyInheritanceStruct"); + uint32_t type_size = KeyedEmptyInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedEmptyInheritanceStruct_max_key_cdr_typesize > 16 ? KeyedEmptyInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedEmptyInheritanceStruct_max_key_cdr_typesize > 16 ? KeyedEmptyInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedEmptyInheritanceStructPubSubType::~KeyedEmptyInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedEmptyInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool KeyedEmptyInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedEmptyInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool KeyedEmptyInheritanceStructPubSubType::deserialize( KeyedEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool KeyedEmptyInheritanceStructPubSubType::deserialize( return true; } -std::function KeyedEmptyInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedEmptyInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedEmptyInheritanceStructPubSubType::createData() + 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* KeyedEmptyInheritanceStructPubSubType::create_data() { return reinterpret_cast(new KeyedEmptyInheritanceStruct()); } -void KeyedEmptyInheritanceStructPubSubType::deleteData( +void KeyedEmptyInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedEmptyInheritanceStructPubSubType::getKey( +bool KeyedEmptyInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedEmptyInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedEmptyInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool KeyedEmptyInheritanceStructPubSubType::getKey( const KeyedEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedEmptyInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedEmptyInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void KeyedEmptyInheritanceStructPubSubType::register_type_object_representation( KeyedInheritanceStructPubSubType::KeyedInheritanceStructPubSubType() { - setName("KeyedInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedInheritanceStruct::getMaxCdrSerializedSize()); -#else - KeyedInheritanceStruct_max_cdr_typesize; -#endif + set_name("KeyedInheritanceStruct"); + uint32_t type_size = KeyedInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyedInheritanceStruct_max_key_cdr_typesize > 16 ? KeyedInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyedInheritanceStruct_max_key_cdr_typesize > 16 ? KeyedInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyedInheritanceStructPubSubType::~KeyedInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyedInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyedInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool KeyedInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyedInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool KeyedInheritanceStructPubSubType::deserialize( KeyedInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool KeyedInheritanceStructPubSubType::deserialize( return true; } -std::function KeyedInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t KeyedInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* KeyedInheritanceStructPubSubType::createData() + 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* KeyedInheritanceStructPubSubType::create_data() { return reinterpret_cast(new KeyedInheritanceStruct()); } -void KeyedInheritanceStructPubSubType::deleteData( +void KeyedInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyedInheritanceStructPubSubType::getKey( +bool KeyedInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyedInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyedInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool KeyedInheritanceStructPubSubType::getKey( const KeyedInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyedInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void KeyedInheritanceStructPubSubType::register_type_object_representation() InheritanceKeyedEmptyStructPubSubType::InheritanceKeyedEmptyStructPubSubType() { - setName("InheritanceKeyedEmptyStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InheritanceKeyedEmptyStruct::getMaxCdrSerializedSize()); -#else - InheritanceKeyedEmptyStruct_max_cdr_typesize; -#endif + set_name("InheritanceKeyedEmptyStruct"); + uint32_t type_size = InheritanceKeyedEmptyStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = InheritanceKeyedEmptyStruct_max_key_cdr_typesize > 16 ? InheritanceKeyedEmptyStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = InheritanceKeyedEmptyStruct_max_key_cdr_typesize > 16 ? InheritanceKeyedEmptyStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InheritanceKeyedEmptyStructPubSubType::~InheritanceKeyedEmptyStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InheritanceKeyedEmptyStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InheritanceKeyedEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool InheritanceKeyedEmptyStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InheritanceKeyedEmptyStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool InheritanceKeyedEmptyStructPubSubType::deserialize( InheritanceKeyedEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool InheritanceKeyedEmptyStructPubSubType::deserialize( return true; } -std::function InheritanceKeyedEmptyStructPubSubType::getSerializedSizeProvider( +uint32_t InheritanceKeyedEmptyStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* InheritanceKeyedEmptyStructPubSubType::createData() + 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* InheritanceKeyedEmptyStructPubSubType::create_data() { return reinterpret_cast(new InheritanceKeyedEmptyStruct()); } -void InheritanceKeyedEmptyStructPubSubType::deleteData( +void InheritanceKeyedEmptyStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InheritanceKeyedEmptyStructPubSubType::getKey( +bool InheritanceKeyedEmptyStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InheritanceKeyedEmptyStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InheritanceKeyedEmptyStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool InheritanceKeyedEmptyStructPubSubType::getKey( const InheritanceKeyedEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InheritanceKeyedEmptyStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InheritanceKeyedEmptyStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/keyPubSubTypes.hpp b/test/dds-types-test/keyPubSubTypes.hpp index 2e292ad59f7..998fc9110b7 100644 --- a/test/dds-types-test/keyPubSubTypes.hpp +++ b/test/dds-types-test/keyPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "key.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated key is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class KeyedShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class KeyedShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class KeyedShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -145,38 +135,30 @@ class KeyedUShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -191,10 +173,6 @@ class KeyedUShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,8 +193,10 @@ class KeyedUShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -236,38 +216,30 @@ class KeyedLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -282,10 +254,6 @@ class KeyedLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -306,8 +274,10 @@ class KeyedLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -327,38 +297,30 @@ class KeyedULongStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -373,10 +335,6 @@ class KeyedULongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -397,8 +355,10 @@ class KeyedULongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -418,38 +378,30 @@ class KeyedLongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -464,10 +416,6 @@ class KeyedLongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -488,8 +436,10 @@ class KeyedLongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -509,38 +459,30 @@ class KeyedULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -555,10 +497,6 @@ class KeyedULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -579,8 +517,10 @@ class KeyedULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -600,38 +540,30 @@ class KeyedFloatStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -646,10 +578,6 @@ class KeyedFloatStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -670,8 +598,10 @@ class KeyedFloatStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -691,38 +621,30 @@ class KeyedDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -737,10 +659,6 @@ class KeyedDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -761,8 +679,10 @@ class KeyedDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -782,38 +702,30 @@ class KeyedLongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -828,10 +740,6 @@ class KeyedLongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -852,8 +760,10 @@ class KeyedLongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -873,38 +783,30 @@ class KeyedBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -919,10 +821,6 @@ class KeyedBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -943,8 +841,10 @@ class KeyedBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -964,38 +864,30 @@ class KeyedOctetStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1010,10 +902,6 @@ class KeyedOctetStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1034,8 +922,10 @@ class KeyedOctetStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1055,38 +945,30 @@ class KeyedCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1101,10 +983,6 @@ class KeyedCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1125,8 +1003,10 @@ class KeyedCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1146,38 +1026,30 @@ class KeyedWCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1192,10 +1064,6 @@ class KeyedWCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1216,8 +1084,10 @@ class KeyedWCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1237,38 +1107,30 @@ class KeyedEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1283,10 +1145,6 @@ class KeyedEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1307,8 +1165,10 @@ class KeyedEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1328,38 +1188,30 @@ class KeyedEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1374,10 +1226,6 @@ class KeyedEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1398,8 +1246,10 @@ class KeyedEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1419,38 +1269,30 @@ class KeyedInheritanceStructPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1465,10 +1307,6 @@ class KeyedInheritanceStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1489,8 +1327,10 @@ class KeyedInheritanceStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1510,38 +1350,30 @@ class InheritanceKeyedEmptyStructPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1556,10 +1388,6 @@ class InheritanceKeyedEmptyStructPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1580,8 +1408,10 @@ class InheritanceKeyedEmptyStructPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/mapsPubSubTypes.cxx b/test/dds-types-test/mapsPubSubTypes.cxx index 3107283f9df..7652da364df 100644 --- a/test/dds-types-test/mapsPubSubTypes.cxx +++ b/test/dds-types-test/mapsPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; MapShortShortPubSubType::MapShortShortPubSubType() { - setName("MapShortShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortShort::getMaxCdrSerializedSize()); -#else - MapShortShort_max_cdr_typesize; -#endif + set_name("MapShortShort"); + uint32_t type_size = MapShortShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortShort_max_key_cdr_typesize > 16 ? MapShortShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortShort_max_key_cdr_typesize > 16 ? MapShortShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortShortPubSubType::~MapShortShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool MapShortShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool MapShortShortPubSubType::deserialize( MapShortShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool MapShortShortPubSubType::deserialize( return true; } -std::function MapShortShortPubSubType::getSerializedSizeProvider( +uint32_t MapShortShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortShortPubSubType::createData() +void* MapShortShortPubSubType::create_data() { return reinterpret_cast(new MapShortShort()); } -void MapShortShortPubSubType::deleteData( +void MapShortShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortShortPubSubType::getKey( +bool MapShortShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool MapShortShortPubSubType::getKey( const MapShortShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void MapShortShortPubSubType::register_type_object_representation() MapShortUShortPubSubType::MapShortUShortPubSubType() { - setName("MapShortUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortUShort::getMaxCdrSerializedSize()); -#else - MapShortUShort_max_cdr_typesize; -#endif + set_name("MapShortUShort"); + uint32_t type_size = MapShortUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortUShort_max_key_cdr_typesize > 16 ? MapShortUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortUShort_max_key_cdr_typesize > 16 ? MapShortUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortUShortPubSubType::~MapShortUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool MapShortUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool MapShortUShortPubSubType::deserialize( MapShortUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool MapShortUShortPubSubType::deserialize( return true; } -std::function MapShortUShortPubSubType::getSerializedSizeProvider( +uint32_t MapShortUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortUShortPubSubType::createData() +void* MapShortUShortPubSubType::create_data() { return reinterpret_cast(new MapShortUShort()); } -void MapShortUShortPubSubType::deleteData( +void MapShortUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortUShortPubSubType::getKey( +bool MapShortUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool MapShortUShortPubSubType::getKey( const MapShortUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void MapShortUShortPubSubType::register_type_object_representation() MapShortLongPubSubType::MapShortLongPubSubType() { - setName("MapShortLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortLong::getMaxCdrSerializedSize()); -#else - MapShortLong_max_cdr_typesize; -#endif + set_name("MapShortLong"); + uint32_t type_size = MapShortLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortLong_max_key_cdr_typesize > 16 ? MapShortLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortLong_max_key_cdr_typesize > 16 ? MapShortLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortLongPubSubType::~MapShortLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool MapShortLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool MapShortLongPubSubType::deserialize( MapShortLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool MapShortLongPubSubType::deserialize( return true; } -std::function MapShortLongPubSubType::getSerializedSizeProvider( +uint32_t MapShortLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortLongPubSubType::createData() +void* MapShortLongPubSubType::create_data() { return reinterpret_cast(new MapShortLong()); } -void MapShortLongPubSubType::deleteData( +void MapShortLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortLongPubSubType::getKey( +bool MapShortLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool MapShortLongPubSubType::getKey( const MapShortLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void MapShortLongPubSubType::register_type_object_representation() MapShortULongPubSubType::MapShortULongPubSubType() { - setName("MapShortULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortULong::getMaxCdrSerializedSize()); -#else - MapShortULong_max_cdr_typesize; -#endif + set_name("MapShortULong"); + uint32_t type_size = MapShortULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortULong_max_key_cdr_typesize > 16 ? MapShortULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortULong_max_key_cdr_typesize > 16 ? MapShortULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortULongPubSubType::~MapShortULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool MapShortULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool MapShortULongPubSubType::deserialize( MapShortULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool MapShortULongPubSubType::deserialize( return true; } -std::function MapShortULongPubSubType::getSerializedSizeProvider( +uint32_t MapShortULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortULongPubSubType::createData() +void* MapShortULongPubSubType::create_data() { return reinterpret_cast(new MapShortULong()); } -void MapShortULongPubSubType::deleteData( +void MapShortULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortULongPubSubType::getKey( +bool MapShortULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool MapShortULongPubSubType::getKey( const MapShortULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void MapShortULongPubSubType::register_type_object_representation() MapShortLongLongPubSubType::MapShortLongLongPubSubType() { - setName("MapShortLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortLongLong::getMaxCdrSerializedSize()); -#else - MapShortLongLong_max_cdr_typesize; -#endif + set_name("MapShortLongLong"); + uint32_t type_size = MapShortLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortLongLong_max_key_cdr_typesize > 16 ? MapShortLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortLongLong_max_key_cdr_typesize > 16 ? MapShortLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortLongLongPubSubType::~MapShortLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool MapShortLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool MapShortLongLongPubSubType::deserialize( MapShortLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool MapShortLongLongPubSubType::deserialize( return true; } -std::function MapShortLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapShortLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortLongLongPubSubType::createData() +void* MapShortLongLongPubSubType::create_data() { return reinterpret_cast(new MapShortLongLong()); } -void MapShortLongLongPubSubType::deleteData( +void MapShortLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortLongLongPubSubType::getKey( +bool MapShortLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool MapShortLongLongPubSubType::getKey( const MapShortLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void MapShortLongLongPubSubType::register_type_object_representation() MapShortULongLongPubSubType::MapShortULongLongPubSubType() { - setName("MapShortULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortULongLong::getMaxCdrSerializedSize()); -#else - MapShortULongLong_max_cdr_typesize; -#endif + set_name("MapShortULongLong"); + uint32_t type_size = MapShortULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortULongLong_max_key_cdr_typesize > 16 ? MapShortULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortULongLong_max_key_cdr_typesize > 16 ? MapShortULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortULongLongPubSubType::~MapShortULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool MapShortULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool MapShortULongLongPubSubType::deserialize( MapShortULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool MapShortULongLongPubSubType::deserialize( return true; } -std::function MapShortULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapShortULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortULongLongPubSubType::createData() +void* MapShortULongLongPubSubType::create_data() { return reinterpret_cast(new MapShortULongLong()); } -void MapShortULongLongPubSubType::deleteData( +void MapShortULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortULongLongPubSubType::getKey( +bool MapShortULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool MapShortULongLongPubSubType::getKey( const MapShortULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void MapShortULongLongPubSubType::register_type_object_representation() MapShortFloatPubSubType::MapShortFloatPubSubType() { - setName("MapShortFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortFloat::getMaxCdrSerializedSize()); -#else - MapShortFloat_max_cdr_typesize; -#endif + set_name("MapShortFloat"); + uint32_t type_size = MapShortFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortFloat_max_key_cdr_typesize > 16 ? MapShortFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortFloat_max_key_cdr_typesize > 16 ? MapShortFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortFloatPubSubType::~MapShortFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool MapShortFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool MapShortFloatPubSubType::deserialize( MapShortFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool MapShortFloatPubSubType::deserialize( return true; } -std::function MapShortFloatPubSubType::getSerializedSizeProvider( +uint32_t MapShortFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortFloatPubSubType::createData() +void* MapShortFloatPubSubType::create_data() { return reinterpret_cast(new MapShortFloat()); } -void MapShortFloatPubSubType::deleteData( +void MapShortFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortFloatPubSubType::getKey( +bool MapShortFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool MapShortFloatPubSubType::getKey( const MapShortFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void MapShortFloatPubSubType::register_type_object_representation() MapShortDoublePubSubType::MapShortDoublePubSubType() { - setName("MapShortDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortDouble::getMaxCdrSerializedSize()); -#else - MapShortDouble_max_cdr_typesize; -#endif + set_name("MapShortDouble"); + uint32_t type_size = MapShortDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortDouble_max_key_cdr_typesize > 16 ? MapShortDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortDouble_max_key_cdr_typesize > 16 ? MapShortDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortDoublePubSubType::~MapShortDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool MapShortDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool MapShortDoublePubSubType::deserialize( MapShortDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,336 +1377,138 @@ bool MapShortDoublePubSubType::deserialize( return true; } -std::function MapShortDoublePubSubType::getSerializedSizeProvider( +uint32_t MapShortDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapShortDoublePubSubType::createData() -{ - return reinterpret_cast(new MapShortDouble()); -} - -void MapShortDoublePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapShortDoublePubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapShortDouble* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapShortDouble_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapShortDouble_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapShortDoublePubSubType::register_type_object_representation() -{ - register_MapShortDouble_type_identifier(type_identifiers_); } -MapShortLongDoublePubSubType::MapShortLongDoublePubSubType() +void* MapShortDoublePubSubType::create_data() { - setName("MapShortLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortLongDouble::getMaxCdrSerializedSize()); -#else - MapShortLongDouble_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortLongDouble_max_key_cdr_typesize > 16 ? MapShortLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapShortDouble()); } -MapShortLongDoublePubSubType::~MapShortLongDoublePubSubType() +void MapShortDoublePubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapShortLongDoublePubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapShortDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapShortLongDouble* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapShortLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapShortLongDouble* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapShortDouble data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapShortLongDoublePubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapShortLongDoublePubSubType::createData() -{ - return reinterpret_cast(new MapShortLongDouble()); -} - -void MapShortLongDoublePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapShortLongDoublePubSubType::getKey( +bool MapShortDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapShortLongDouble* p_type = static_cast(data); + const MapShortDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapShortLongDouble_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapShortDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapShortLongDouble_max_key_cdr_typesize > 16) + if (force_md5 || MapShortDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapShortLongDoublePubSubType::register_type_object_representation() +void MapShortDoublePubSubType::register_type_object_representation() { - register_MapShortLongDouble_type_identifier(type_identifiers_); + register_MapShortDouble_type_identifier(type_identifiers_); } -MapShortBooleanPubSubType::MapShortBooleanPubSubType() +MapShortLongDoublePubSubType::MapShortLongDoublePubSubType() { - setName("MapShortBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortBoolean::getMaxCdrSerializedSize()); -#else - MapShortBoolean_max_cdr_typesize; -#endif + set_name("MapShortLongDouble"); + uint32_t type_size = MapShortLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortBoolean_max_key_cdr_typesize > 16 ? MapShortBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortLongDouble_max_key_cdr_typesize > 16 ? MapShortLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapShortBooleanPubSubType::~MapShortBooleanPubSubType() +MapShortLongDoublePubSubType::~MapShortLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapShortBooleanPubSubType::serialize( +bool MapShortLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapShortBoolean* p_type = static_cast(data); + const MapShortLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1523,192 @@ bool MapShortBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapShortLongDoublePubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapShortLongDouble* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapShortLongDoublePubSubType::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* MapShortLongDoublePubSubType::create_data() +{ + return reinterpret_cast(new MapShortLongDouble()); +} + +void MapShortLongDoublePubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapShortLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortLongDoublePubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapShortLongDouble* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapShortLongDouble_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapShortLongDouble_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 MapShortLongDoublePubSubType::register_type_object_representation() +{ + register_MapShortLongDouble_type_identifier(type_identifiers_); +} + +MapShortBooleanPubSubType::MapShortBooleanPubSubType() +{ + set_name("MapShortBoolean"); + uint32_t type_size = MapShortBoolean_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 = MapShortBoolean_max_key_cdr_typesize > 16 ? MapShortBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapShortBooleanPubSubType::~MapShortBooleanPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapShortBooleanPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapShortBoolean* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool MapShortBooleanPubSubType::deserialize( MapShortBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool MapShortBooleanPubSubType::deserialize( return true; } -std::function MapShortBooleanPubSubType::getSerializedSizeProvider( +uint32_t MapShortBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortBooleanPubSubType::createData() +void* MapShortBooleanPubSubType::create_data() { return reinterpret_cast(new MapShortBoolean()); } -void MapShortBooleanPubSubType::deleteData( +void MapShortBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortBooleanPubSubType::getKey( +bool MapShortBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool MapShortBooleanPubSubType::getKey( const MapShortBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void MapShortBooleanPubSubType::register_type_object_representation() MapShortOctetPubSubType::MapShortOctetPubSubType() { - setName("MapShortOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortOctet::getMaxCdrSerializedSize()); -#else - MapShortOctet_max_cdr_typesize; -#endif + set_name("MapShortOctet"); + uint32_t type_size = MapShortOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortOctet_max_key_cdr_typesize > 16 ? MapShortOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortOctet_max_key_cdr_typesize > 16 ? MapShortOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortOctetPubSubType::~MapShortOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool MapShortOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool MapShortOctetPubSubType::deserialize( MapShortOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool MapShortOctetPubSubType::deserialize( return true; } -std::function MapShortOctetPubSubType::getSerializedSizeProvider( +uint32_t MapShortOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortOctetPubSubType::createData() +void* MapShortOctetPubSubType::create_data() { return reinterpret_cast(new MapShortOctet()); } -void MapShortOctetPubSubType::deleteData( +void MapShortOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortOctetPubSubType::getKey( +bool MapShortOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool MapShortOctetPubSubType::getKey( const MapShortOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void MapShortOctetPubSubType::register_type_object_representation() MapShortCharPubSubType::MapShortCharPubSubType() { - setName("MapShortChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortChar::getMaxCdrSerializedSize()); -#else - MapShortChar_max_cdr_typesize; -#endif + set_name("MapShortChar"); + uint32_t type_size = MapShortChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortChar_max_key_cdr_typesize > 16 ? MapShortChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortChar_max_key_cdr_typesize > 16 ? MapShortChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortCharPubSubType::~MapShortCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool MapShortCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool MapShortCharPubSubType::deserialize( MapShortChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool MapShortCharPubSubType::deserialize( return true; } -std::function MapShortCharPubSubType::getSerializedSizeProvider( +uint32_t MapShortCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortCharPubSubType::createData() +void* MapShortCharPubSubType::create_data() { return reinterpret_cast(new MapShortChar()); } -void MapShortCharPubSubType::deleteData( +void MapShortCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortCharPubSubType::getKey( +bool MapShortCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool MapShortCharPubSubType::getKey( const MapShortChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void MapShortCharPubSubType::register_type_object_representation() MapShortWCharPubSubType::MapShortWCharPubSubType() { - setName("MapShortWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortWChar::getMaxCdrSerializedSize()); -#else - MapShortWChar_max_cdr_typesize; -#endif + set_name("MapShortWChar"); + uint32_t type_size = MapShortWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortWChar_max_key_cdr_typesize > 16 ? MapShortWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortWChar_max_key_cdr_typesize > 16 ? MapShortWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortWCharPubSubType::~MapShortWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool MapShortWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool MapShortWCharPubSubType::deserialize( MapShortWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,52 +2277,62 @@ bool MapShortWCharPubSubType::deserialize( return true; } -std::function MapShortWCharPubSubType::getSerializedSizeProvider( +uint32_t MapShortWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortWCharPubSubType::createData() +void* MapShortWCharPubSubType::create_data() { return reinterpret_cast(new MapShortWChar()); } -void MapShortWCharPubSubType::deleteData( +void MapShortWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortWCharPubSubType::getKey( +bool MapShortWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2501,35 +2340,27 @@ bool MapShortWCharPubSubType::getKey( const MapShortWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void MapShortWCharPubSubType::register_type_object_representation() MapShortStringPubSubType::MapShortStringPubSubType() { - setName("MapShortString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortString::getMaxCdrSerializedSize()); -#else - MapShortString_max_cdr_typesize; -#endif + set_name("MapShortString"); + uint32_t type_size = MapShortString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortString_max_key_cdr_typesize > 16 ? MapShortString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortString_max_key_cdr_typesize > 16 ? MapShortString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortStringPubSubType::~MapShortStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool MapShortStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool MapShortStringPubSubType::deserialize( MapShortString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool MapShortStringPubSubType::deserialize( return true; } -std::function MapShortStringPubSubType::getSerializedSizeProvider( +uint32_t MapShortStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortStringPubSubType::createData() +void* MapShortStringPubSubType::create_data() { return reinterpret_cast(new MapShortString()); } -void MapShortStringPubSubType::deleteData( +void MapShortStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortStringPubSubType::getKey( +bool MapShortStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool MapShortStringPubSubType::getKey( const MapShortString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void MapShortStringPubSubType::register_type_object_representation() MapShortWStringPubSubType::MapShortWStringPubSubType() { - setName("MapShortWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortWString::getMaxCdrSerializedSize()); -#else - MapShortWString_max_cdr_typesize; -#endif + set_name("MapShortWString"); + uint32_t type_size = MapShortWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortWString_max_key_cdr_typesize > 16 ? MapShortWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortWString_max_key_cdr_typesize > 16 ? MapShortWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortWStringPubSubType::~MapShortWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool MapShortWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool MapShortWStringPubSubType::deserialize( MapShortWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool MapShortWStringPubSubType::deserialize( return true; } -std::function MapShortWStringPubSubType::getSerializedSizeProvider( +uint32_t MapShortWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortWStringPubSubType::createData() +void* MapShortWStringPubSubType::create_data() { return reinterpret_cast(new MapShortWString()); } -void MapShortWStringPubSubType::deleteData( +void MapShortWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortWStringPubSubType::getKey( +bool MapShortWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool MapShortWStringPubSubType::getKey( const MapShortWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void MapShortWStringPubSubType::register_type_object_representation() MapShortInnerAliasBoundedStringHelperPubSubType::MapShortInnerAliasBoundedStringHelperPubSubType() { - setName("MapShortInnerAliasBoundedStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerAliasBoundedStringHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerAliasBoundedStringHelper_max_cdr_typesize; -#endif + set_name("MapShortInnerAliasBoundedStringHelper"); + uint32_t type_size = MapShortInnerAliasBoundedStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortInnerAliasBoundedStringHelperPubSubType::~MapShortInnerAliasBoundedStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortInnerAliasBoundedStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool MapShortInnerAliasBoundedStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortInnerAliasBoundedStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool MapShortInnerAliasBoundedStringHelperPubSubType::deserialize( MapShortInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool MapShortInnerAliasBoundedStringHelperPubSubType::deserialize( return true; } -std::function MapShortInnerAliasBoundedStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapShortInnerAliasBoundedStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortInnerAliasBoundedStringHelperPubSubType::createData() +void* MapShortInnerAliasBoundedStringHelperPubSubType::create_data() { return reinterpret_cast(new MapShortInnerAliasBoundedStringHelper()); } -void MapShortInnerAliasBoundedStringHelperPubSubType::deleteData( +void MapShortInnerAliasBoundedStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortInnerAliasBoundedStringHelperPubSubType::getKey( +bool MapShortInnerAliasBoundedStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortInnerAliasBoundedStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortInnerAliasBoundedStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool MapShortInnerAliasBoundedStringHelperPubSubType::getKey( const MapShortInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortInnerAliasBoundedStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void MapShortInnerAliasBoundedStringHelperPubSubType::register_type_object_repre MapShortInnerAliasBoundedWStringHelperPubSubType::MapShortInnerAliasBoundedWStringHelperPubSubType() { - setName("MapShortInnerAliasBoundedWStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerAliasBoundedWStringHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerAliasBoundedWStringHelper_max_cdr_typesize; -#endif + set_name("MapShortInnerAliasBoundedWStringHelper"); + uint32_t type_size = MapShortInnerAliasBoundedWStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortInnerAliasBoundedWStringHelperPubSubType::~MapShortInnerAliasBoundedWStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortInnerAliasBoundedWStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool MapShortInnerAliasBoundedWStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortInnerAliasBoundedWStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool MapShortInnerAliasBoundedWStringHelperPubSubType::deserialize( MapShortInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool MapShortInnerAliasBoundedWStringHelperPubSubType::deserialize( return true; } -std::function MapShortInnerAliasBoundedWStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapShortInnerAliasBoundedWStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortInnerAliasBoundedWStringHelperPubSubType::createData() +void* MapShortInnerAliasBoundedWStringHelperPubSubType::create_data() { return reinterpret_cast(new MapShortInnerAliasBoundedWStringHelper()); } -void MapShortInnerAliasBoundedWStringHelperPubSubType::deleteData( +void MapShortInnerAliasBoundedWStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortInnerAliasBoundedWStringHelperPubSubType::getKey( +bool MapShortInnerAliasBoundedWStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortInnerAliasBoundedWStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortInnerAliasBoundedWStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool MapShortInnerAliasBoundedWStringHelperPubSubType::getKey( const MapShortInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void MapShortInnerAliasBoundedWStringHelperPubSubType::register_type_object_repr MapShortInnerEnumHelperPubSubType::MapShortInnerEnumHelperPubSubType() { - setName("MapShortInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerEnumHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerEnumHelper_max_cdr_typesize; -#endif + set_name("MapShortInnerEnumHelper"); + uint32_t type_size = MapShortInnerEnumHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerEnumHelper_max_key_cdr_typesize > 16 ? MapShortInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortInnerEnumHelper_max_key_cdr_typesize > 16 ? MapShortInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortInnerEnumHelperPubSubType::~MapShortInnerEnumHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortInnerEnumHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool MapShortInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool MapShortInnerEnumHelperPubSubType::deserialize( MapShortInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool MapShortInnerEnumHelperPubSubType::deserialize( return true; } -std::function MapShortInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t MapShortInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortInnerEnumHelperPubSubType::createData() +void* MapShortInnerEnumHelperPubSubType::create_data() { return reinterpret_cast(new MapShortInnerEnumHelper()); } -void MapShortInnerEnumHelperPubSubType::deleteData( +void MapShortInnerEnumHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortInnerEnumHelperPubSubType::getKey( +bool MapShortInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool MapShortInnerEnumHelperPubSubType::getKey( const MapShortInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void MapShortInnerEnumHelperPubSubType::register_type_object_representation() MapShortInnerBitMaskHelperPubSubType::MapShortInnerBitMaskHelperPubSubType() { - setName("MapShortInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerBitMaskHelper_max_cdr_typesize; -#endif + set_name("MapShortInnerBitMaskHelper"); + uint32_t type_size = MapShortInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapShortInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapShortInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortInnerBitMaskHelperPubSubType::~MapShortInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool MapShortInnerBitMaskHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool MapShortInnerBitMaskHelperPubSubType::deserialize( MapShortInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool MapShortInnerBitMaskHelperPubSubType::deserialize( return true; } -std::function MapShortInnerBitMaskHelperPubSubType::getSerializedSizeProvider( +uint32_t MapShortInnerBitMaskHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortInnerBitMaskHelperPubSubType::createData() +void* MapShortInnerBitMaskHelperPubSubType::create_data() { return reinterpret_cast(new MapShortInnerBitMaskHelper()); } -void MapShortInnerBitMaskHelperPubSubType::deleteData( +void MapShortInnerBitMaskHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortInnerBitMaskHelperPubSubType::getKey( +bool MapShortInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortInnerBitMaskHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool MapShortInnerBitMaskHelperPubSubType::getKey( const MapShortInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortInnerBitMaskHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortInnerBitMaskHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3700,49 +3453,42 @@ void MapShortInnerBitMaskHelperPubSubType::register_type_object_representation() MapShortInnerAliasHelperPubSubType::MapShortInnerAliasHelperPubSubType() { - setName("MapShortInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerAliasHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerAliasHelper_max_cdr_typesize; -#endif + set_name("MapShortInnerAliasHelper"); + uint32_t type_size = MapShortInnerAliasHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerAliasHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortInnerAliasHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortInnerAliasHelperPubSubType::~MapShortInnerAliasHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortInnerAliasHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3757,16 +3503,12 @@ bool MapShortInnerAliasHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3775,18 +3517,14 @@ bool MapShortInnerAliasHelperPubSubType::deserialize( MapShortInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3799,52 +3537,62 @@ bool MapShortInnerAliasHelperPubSubType::deserialize( return true; } -std::function MapShortInnerAliasHelperPubSubType::getSerializedSizeProvider( +uint32_t MapShortInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortInnerAliasHelperPubSubType::createData() +void* MapShortInnerAliasHelperPubSubType::create_data() { return reinterpret_cast(new MapShortInnerAliasHelper()); } -void MapShortInnerAliasHelperPubSubType::deleteData( +void MapShortInnerAliasHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortInnerAliasHelperPubSubType::getKey( +bool MapShortInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3852,35 +3600,27 @@ bool MapShortInnerAliasHelperPubSubType::getKey( const MapShortInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3893,49 +3633,42 @@ void MapShortInnerAliasHelperPubSubType::register_type_object_representation() MapShortInnerAliasArrayHelperPubSubType::MapShortInnerAliasArrayHelperPubSubType() { - setName("MapShortInnerAliasArrayHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerAliasArrayHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerAliasArrayHelper_max_cdr_typesize; -#endif + set_name("MapShortInnerAliasArrayHelper"); + uint32_t type_size = MapShortInnerAliasArrayHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasArrayHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasArrayHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortInnerAliasArrayHelperPubSubType::~MapShortInnerAliasArrayHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortInnerAliasArrayHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3950,16 +3683,12 @@ bool MapShortInnerAliasArrayHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortInnerAliasArrayHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3968,18 +3697,14 @@ bool MapShortInnerAliasArrayHelperPubSubType::deserialize( MapShortInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3992,52 +3717,62 @@ bool MapShortInnerAliasArrayHelperPubSubType::deserialize( return true; } -std::function MapShortInnerAliasArrayHelperPubSubType::getSerializedSizeProvider( +uint32_t MapShortInnerAliasArrayHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortInnerAliasArrayHelperPubSubType::createData() +void* MapShortInnerAliasArrayHelperPubSubType::create_data() { return reinterpret_cast(new MapShortInnerAliasArrayHelper()); } -void MapShortInnerAliasArrayHelperPubSubType::deleteData( +void MapShortInnerAliasArrayHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortInnerAliasArrayHelperPubSubType::getKey( +bool MapShortInnerAliasArrayHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortInnerAliasArrayHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortInnerAliasArrayHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4045,35 +3780,27 @@ bool MapShortInnerAliasArrayHelperPubSubType::getKey( const MapShortInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortInnerAliasArrayHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortInnerAliasArrayHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4086,49 +3813,42 @@ void MapShortInnerAliasArrayHelperPubSubType::register_type_object_representatio MapShortInnerAliasSequenceHelperPubSubType::MapShortInnerAliasSequenceHelperPubSubType() { - setName("MapShortInnerAliasSequenceHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerAliasSequenceHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerAliasSequenceHelper_max_cdr_typesize; -#endif + set_name("MapShortInnerAliasSequenceHelper"); + uint32_t type_size = MapShortInnerAliasSequenceHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasSequenceHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasSequenceHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortInnerAliasSequenceHelperPubSubType::~MapShortInnerAliasSequenceHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortInnerAliasSequenceHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4143,16 +3863,12 @@ bool MapShortInnerAliasSequenceHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortInnerAliasSequenceHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4161,18 +3877,14 @@ bool MapShortInnerAliasSequenceHelperPubSubType::deserialize( MapShortInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4185,52 +3897,62 @@ bool MapShortInnerAliasSequenceHelperPubSubType::deserialize( return true; } -std::function MapShortInnerAliasSequenceHelperPubSubType::getSerializedSizeProvider( +uint32_t MapShortInnerAliasSequenceHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortInnerAliasSequenceHelperPubSubType::createData() +void* MapShortInnerAliasSequenceHelperPubSubType::create_data() { return reinterpret_cast(new MapShortInnerAliasSequenceHelper()); } -void MapShortInnerAliasSequenceHelperPubSubType::deleteData( +void MapShortInnerAliasSequenceHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortInnerAliasSequenceHelperPubSubType::getKey( +bool MapShortInnerAliasSequenceHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortInnerAliasSequenceHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortInnerAliasSequenceHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4238,35 +3960,27 @@ bool MapShortInnerAliasSequenceHelperPubSubType::getKey( const MapShortInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortInnerAliasSequenceHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortInnerAliasSequenceHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4279,49 +3993,42 @@ void MapShortInnerAliasSequenceHelperPubSubType::register_type_object_representa MapShortInnerAliasMapHelperPubSubType::MapShortInnerAliasMapHelperPubSubType() { - setName("MapShortInnerAliasMapHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerAliasMapHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerAliasMapHelper_max_cdr_typesize; -#endif + set_name("MapShortInnerAliasMapHelper"); + uint32_t type_size = MapShortInnerAliasMapHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasMapHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapShortInnerAliasMapHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortInnerAliasMapHelperPubSubType::~MapShortInnerAliasMapHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortInnerAliasMapHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4336,16 +4043,12 @@ bool MapShortInnerAliasMapHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortInnerAliasMapHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4354,18 +4057,14 @@ bool MapShortInnerAliasMapHelperPubSubType::deserialize( MapShortInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4378,52 +4077,62 @@ bool MapShortInnerAliasMapHelperPubSubType::deserialize( return true; } -std::function MapShortInnerAliasMapHelperPubSubType::getSerializedSizeProvider( +uint32_t MapShortInnerAliasMapHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortInnerAliasMapHelperPubSubType::createData() +void* MapShortInnerAliasMapHelperPubSubType::create_data() { return reinterpret_cast(new MapShortInnerAliasMapHelper()); } -void MapShortInnerAliasMapHelperPubSubType::deleteData( +void MapShortInnerAliasMapHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortInnerAliasMapHelperPubSubType::getKey( +bool MapShortInnerAliasMapHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortInnerAliasMapHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortInnerAliasMapHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4431,35 +4140,27 @@ bool MapShortInnerAliasMapHelperPubSubType::getKey( const MapShortInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortInnerAliasMapHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortInnerAliasMapHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4472,49 +4173,42 @@ void MapShortInnerAliasMapHelperPubSubType::register_type_object_representation( MapShortInnerUnionHelperPubSubType::MapShortInnerUnionHelperPubSubType() { - setName("MapShortInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerUnionHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerUnionHelper_max_cdr_typesize; -#endif + set_name("MapShortInnerUnionHelper"); + uint32_t type_size = MapShortInnerUnionHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerUnionHelper_max_key_cdr_typesize > 16 ? MapShortInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortInnerUnionHelper_max_key_cdr_typesize > 16 ? MapShortInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapShortInnerUnionHelperPubSubType::~MapShortInnerUnionHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapShortInnerUnionHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapShortInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4529,16 +4223,12 @@ bool MapShortInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4547,18 +4237,14 @@ bool MapShortInnerUnionHelperPubSubType::deserialize( MapShortInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4571,336 +4257,138 @@ bool MapShortInnerUnionHelperPubSubType::deserialize( return true; } -std::function MapShortInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t MapShortInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapShortInnerUnionHelperPubSubType::createData() -{ - return reinterpret_cast(new MapShortInnerUnionHelper()); -} - -void MapShortInnerUnionHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapShortInnerUnionHelperPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapShortInnerUnionHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapShortInnerUnionHelper_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapShortInnerUnionHelper_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapShortInnerUnionHelperPubSubType::register_type_object_representation() -{ - register_MapShortInnerUnionHelper_type_identifier(type_identifiers_); } -MapShortInnerStructureHelperPubSubType::MapShortInnerStructureHelperPubSubType() +void* MapShortInnerUnionHelperPubSubType::create_data() { - setName("MapShortInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerStructureHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerStructureHelper_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerStructureHelper_max_key_cdr_typesize > 16 ? MapShortInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapShortInnerUnionHelper()); } -MapShortInnerStructureHelperPubSubType::~MapShortInnerStructureHelperPubSubType() +void MapShortInnerUnionHelperPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapShortInnerStructureHelperPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapShortInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapShortInnerStructureHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapShortInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapShortInnerStructureHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapShortInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapShortInnerStructureHelperPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapShortInnerStructureHelperPubSubType::createData() -{ - return reinterpret_cast(new MapShortInnerStructureHelper()); -} - -void MapShortInnerStructureHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapShortInnerStructureHelperPubSubType::getKey( +bool MapShortInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapShortInnerStructureHelper* p_type = static_cast(data); + const MapShortInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapShortInnerStructureHelper_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapShortInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapShortInnerStructureHelper_max_key_cdr_typesize > 16) + if (force_md5 || MapShortInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapShortInnerStructureHelperPubSubType::register_type_object_representation() +void MapShortInnerUnionHelperPubSubType::register_type_object_representation() { - register_MapShortInnerStructureHelper_type_identifier(type_identifiers_); + register_MapShortInnerUnionHelper_type_identifier(type_identifiers_); } -MapShortInnerBitsetHelperPubSubType::MapShortInnerBitsetHelperPubSubType() +MapShortInnerStructureHelperPubSubType::MapShortInnerStructureHelperPubSubType() { - setName("MapShortInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapShortInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - MapShortInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("MapShortInnerStructureHelper"); + uint32_t type_size = MapShortInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapShortInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapShortInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapShortInnerStructureHelper_max_key_cdr_typesize > 16 ? MapShortInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapShortInnerBitsetHelperPubSubType::~MapShortInnerBitsetHelperPubSubType() +MapShortInnerStructureHelperPubSubType::~MapShortInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapShortInnerBitsetHelperPubSubType::serialize( +bool MapShortInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapShortInnerBitsetHelper* p_type = static_cast(data); + const MapShortInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4915,16 +4403,192 @@ bool MapShortInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapShortInnerStructureHelperPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapShortInnerStructureHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapShortInnerStructureHelperPubSubType::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* MapShortInnerStructureHelperPubSubType::create_data() +{ + return reinterpret_cast(new MapShortInnerStructureHelper()); +} + +void MapShortInnerStructureHelperPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapShortInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortInnerStructureHelperPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapShortInnerStructureHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapShortInnerStructureHelper_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapShortInnerStructureHelper_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 MapShortInnerStructureHelperPubSubType::register_type_object_representation() +{ + register_MapShortInnerStructureHelper_type_identifier(type_identifiers_); +} + +MapShortInnerBitsetHelperPubSubType::MapShortInnerBitsetHelperPubSubType() +{ + set_name("MapShortInnerBitsetHelper"); + uint32_t type_size = MapShortInnerBitsetHelper_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 = MapShortInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapShortInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapShortInnerBitsetHelperPubSubType::~MapShortInnerBitsetHelperPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapShortInnerBitsetHelperPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapShortInnerBitsetHelper* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapShortInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4933,18 +4597,14 @@ bool MapShortInnerBitsetHelperPubSubType::deserialize( MapShortInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4957,52 +4617,62 @@ bool MapShortInnerBitsetHelperPubSubType::deserialize( return true; } -std::function MapShortInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t MapShortInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapShortInnerBitsetHelperPubSubType::createData() +void* MapShortInnerBitsetHelperPubSubType::create_data() { return reinterpret_cast(new MapShortInnerBitsetHelper()); } -void MapShortInnerBitsetHelperPubSubType::deleteData( +void MapShortInnerBitsetHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapShortInnerBitsetHelperPubSubType::getKey( +bool MapShortInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapShortInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapShortInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5010,35 +4680,27 @@ bool MapShortInnerBitsetHelperPubSubType::getKey( const MapShortInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapShortInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapShortInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5051,49 +4713,42 @@ void MapShortInnerBitsetHelperPubSubType::register_type_object_representation() MapUShortShortPubSubType::MapUShortShortPubSubType() { - setName("MapUShortShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortShort::getMaxCdrSerializedSize()); -#else - MapUShortShort_max_cdr_typesize; -#endif + set_name("MapUShortShort"); + uint32_t type_size = MapUShortShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortShort_max_key_cdr_typesize > 16 ? MapUShortShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortShort_max_key_cdr_typesize > 16 ? MapUShortShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortShortPubSubType::~MapUShortShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5108,16 +4763,12 @@ bool MapUShortShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5126,18 +4777,14 @@ bool MapUShortShortPubSubType::deserialize( MapUShortShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5150,52 +4797,62 @@ bool MapUShortShortPubSubType::deserialize( return true; } -std::function MapUShortShortPubSubType::getSerializedSizeProvider( +uint32_t MapUShortShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortShortPubSubType::createData() +void* MapUShortShortPubSubType::create_data() { return reinterpret_cast(new MapUShortShort()); } -void MapUShortShortPubSubType::deleteData( +void MapUShortShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortShortPubSubType::getKey( +bool MapUShortShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5203,35 +4860,27 @@ bool MapUShortShortPubSubType::getKey( const MapUShortShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5244,49 +4893,42 @@ void MapUShortShortPubSubType::register_type_object_representation() MapUShortUShortPubSubType::MapUShortUShortPubSubType() { - setName("MapUShortUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortUShort::getMaxCdrSerializedSize()); -#else - MapUShortUShort_max_cdr_typesize; -#endif + set_name("MapUShortUShort"); + uint32_t type_size = MapUShortUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortUShort_max_key_cdr_typesize > 16 ? MapUShortUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortUShort_max_key_cdr_typesize > 16 ? MapUShortUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortUShortPubSubType::~MapUShortUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5301,16 +4943,12 @@ bool MapUShortUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5319,18 +4957,14 @@ bool MapUShortUShortPubSubType::deserialize( MapUShortUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5343,52 +4977,62 @@ bool MapUShortUShortPubSubType::deserialize( return true; } -std::function MapUShortUShortPubSubType::getSerializedSizeProvider( +uint32_t MapUShortUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortUShortPubSubType::createData() +void* MapUShortUShortPubSubType::create_data() { return reinterpret_cast(new MapUShortUShort()); } -void MapUShortUShortPubSubType::deleteData( +void MapUShortUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortUShortPubSubType::getKey( +bool MapUShortUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5396,35 +5040,27 @@ bool MapUShortUShortPubSubType::getKey( const MapUShortUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5437,49 +5073,42 @@ void MapUShortUShortPubSubType::register_type_object_representation() MapUShortLongPubSubType::MapUShortLongPubSubType() { - setName("MapUShortLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortLong::getMaxCdrSerializedSize()); -#else - MapUShortLong_max_cdr_typesize; -#endif + set_name("MapUShortLong"); + uint32_t type_size = MapUShortLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortLong_max_key_cdr_typesize > 16 ? MapUShortLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortLong_max_key_cdr_typesize > 16 ? MapUShortLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortLongPubSubType::~MapUShortLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5494,16 +5123,12 @@ bool MapUShortLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5512,18 +5137,14 @@ bool MapUShortLongPubSubType::deserialize( MapUShortLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5536,52 +5157,62 @@ bool MapUShortLongPubSubType::deserialize( return true; } -std::function MapUShortLongPubSubType::getSerializedSizeProvider( +uint32_t MapUShortLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortLongPubSubType::createData() +void* MapUShortLongPubSubType::create_data() { return reinterpret_cast(new MapUShortLong()); } -void MapUShortLongPubSubType::deleteData( +void MapUShortLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortLongPubSubType::getKey( +bool MapUShortLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5589,35 +5220,27 @@ bool MapUShortLongPubSubType::getKey( const MapUShortLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5630,49 +5253,42 @@ void MapUShortLongPubSubType::register_type_object_representation() MapUShortULongPubSubType::MapUShortULongPubSubType() { - setName("MapUShortULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortULong::getMaxCdrSerializedSize()); -#else - MapUShortULong_max_cdr_typesize; -#endif + set_name("MapUShortULong"); + uint32_t type_size = MapUShortULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortULong_max_key_cdr_typesize > 16 ? MapUShortULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortULong_max_key_cdr_typesize > 16 ? MapUShortULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortULongPubSubType::~MapUShortULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5687,16 +5303,12 @@ bool MapUShortULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5705,18 +5317,14 @@ bool MapUShortULongPubSubType::deserialize( MapUShortULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5729,52 +5337,62 @@ bool MapUShortULongPubSubType::deserialize( return true; } -std::function MapUShortULongPubSubType::getSerializedSizeProvider( +uint32_t MapUShortULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortULongPubSubType::createData() +void* MapUShortULongPubSubType::create_data() { return reinterpret_cast(new MapUShortULong()); } -void MapUShortULongPubSubType::deleteData( +void MapUShortULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortULongPubSubType::getKey( +bool MapUShortULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5782,35 +5400,27 @@ bool MapUShortULongPubSubType::getKey( const MapUShortULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5823,49 +5433,42 @@ void MapUShortULongPubSubType::register_type_object_representation() MapUShortLongLongPubSubType::MapUShortLongLongPubSubType() { - setName("MapUShortLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortLongLong::getMaxCdrSerializedSize()); -#else - MapUShortLongLong_max_cdr_typesize; -#endif + set_name("MapUShortLongLong"); + uint32_t type_size = MapUShortLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortLongLong_max_key_cdr_typesize > 16 ? MapUShortLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortLongLong_max_key_cdr_typesize > 16 ? MapUShortLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortLongLongPubSubType::~MapUShortLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5880,16 +5483,12 @@ bool MapUShortLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5898,18 +5497,14 @@ bool MapUShortLongLongPubSubType::deserialize( MapUShortLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5922,52 +5517,62 @@ bool MapUShortLongLongPubSubType::deserialize( return true; } -std::function MapUShortLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapUShortLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortLongLongPubSubType::createData() +void* MapUShortLongLongPubSubType::create_data() { return reinterpret_cast(new MapUShortLongLong()); } -void MapUShortLongLongPubSubType::deleteData( +void MapUShortLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortLongLongPubSubType::getKey( +bool MapUShortLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5975,35 +5580,27 @@ bool MapUShortLongLongPubSubType::getKey( const MapUShortLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6016,49 +5613,42 @@ void MapUShortLongLongPubSubType::register_type_object_representation() MapUShortULongLongPubSubType::MapUShortULongLongPubSubType() { - setName("MapUShortULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortULongLong::getMaxCdrSerializedSize()); -#else - MapUShortULongLong_max_cdr_typesize; -#endif + set_name("MapUShortULongLong"); + uint32_t type_size = MapUShortULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortULongLong_max_key_cdr_typesize > 16 ? MapUShortULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortULongLong_max_key_cdr_typesize > 16 ? MapUShortULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortULongLongPubSubType::~MapUShortULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6073,16 +5663,12 @@ bool MapUShortULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6091,18 +5677,14 @@ bool MapUShortULongLongPubSubType::deserialize( MapUShortULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6115,52 +5697,62 @@ bool MapUShortULongLongPubSubType::deserialize( return true; } -std::function MapUShortULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapUShortULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortULongLongPubSubType::createData() +void* MapUShortULongLongPubSubType::create_data() { return reinterpret_cast(new MapUShortULongLong()); } -void MapUShortULongLongPubSubType::deleteData( +void MapUShortULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortULongLongPubSubType::getKey( +bool MapUShortULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6168,35 +5760,27 @@ bool MapUShortULongLongPubSubType::getKey( const MapUShortULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6209,49 +5793,42 @@ void MapUShortULongLongPubSubType::register_type_object_representation() MapUShortFloatPubSubType::MapUShortFloatPubSubType() { - setName("MapUShortFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortFloat::getMaxCdrSerializedSize()); -#else - MapUShortFloat_max_cdr_typesize; -#endif + set_name("MapUShortFloat"); + uint32_t type_size = MapUShortFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortFloat_max_key_cdr_typesize > 16 ? MapUShortFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortFloat_max_key_cdr_typesize > 16 ? MapUShortFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortFloatPubSubType::~MapUShortFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6266,16 +5843,12 @@ bool MapUShortFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6284,18 +5857,14 @@ bool MapUShortFloatPubSubType::deserialize( MapUShortFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6308,52 +5877,62 @@ bool MapUShortFloatPubSubType::deserialize( return true; } -std::function MapUShortFloatPubSubType::getSerializedSizeProvider( +uint32_t MapUShortFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortFloatPubSubType::createData() +void* MapUShortFloatPubSubType::create_data() { return reinterpret_cast(new MapUShortFloat()); } -void MapUShortFloatPubSubType::deleteData( +void MapUShortFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortFloatPubSubType::getKey( +bool MapUShortFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6361,35 +5940,27 @@ bool MapUShortFloatPubSubType::getKey( const MapUShortFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6402,49 +5973,42 @@ void MapUShortFloatPubSubType::register_type_object_representation() MapUShortDoublePubSubType::MapUShortDoublePubSubType() { - setName("MapUShortDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortDouble::getMaxCdrSerializedSize()); -#else - MapUShortDouble_max_cdr_typesize; -#endif + set_name("MapUShortDouble"); + uint32_t type_size = MapUShortDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortDouble_max_key_cdr_typesize > 16 ? MapUShortDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortDouble_max_key_cdr_typesize > 16 ? MapUShortDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortDoublePubSubType::~MapUShortDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6459,16 +6023,12 @@ bool MapUShortDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6477,18 +6037,14 @@ bool MapUShortDoublePubSubType::deserialize( MapUShortDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6501,52 +6057,62 @@ bool MapUShortDoublePubSubType::deserialize( return true; } -std::function MapUShortDoublePubSubType::getSerializedSizeProvider( +uint32_t MapUShortDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortDoublePubSubType::createData() +void* MapUShortDoublePubSubType::create_data() { return reinterpret_cast(new MapUShortDouble()); } -void MapUShortDoublePubSubType::deleteData( +void MapUShortDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortDoublePubSubType::getKey( +bool MapUShortDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6554,35 +6120,27 @@ bool MapUShortDoublePubSubType::getKey( const MapUShortDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6595,49 +6153,42 @@ void MapUShortDoublePubSubType::register_type_object_representation() MapUShortLongDoublePubSubType::MapUShortLongDoublePubSubType() { - setName("MapUShortLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortLongDouble::getMaxCdrSerializedSize()); -#else - MapUShortLongDouble_max_cdr_typesize; -#endif + set_name("MapUShortLongDouble"); + uint32_t type_size = MapUShortLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortLongDouble_max_key_cdr_typesize > 16 ? MapUShortLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortLongDouble_max_key_cdr_typesize > 16 ? MapUShortLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortLongDoublePubSubType::~MapUShortLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6652,16 +6203,12 @@ bool MapUShortLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6670,18 +6217,14 @@ bool MapUShortLongDoublePubSubType::deserialize( MapUShortLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6694,52 +6237,62 @@ bool MapUShortLongDoublePubSubType::deserialize( return true; } -std::function MapUShortLongDoublePubSubType::getSerializedSizeProvider( +uint32_t MapUShortLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortLongDoublePubSubType::createData() +void* MapUShortLongDoublePubSubType::create_data() { return reinterpret_cast(new MapUShortLongDouble()); } -void MapUShortLongDoublePubSubType::deleteData( +void MapUShortLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortLongDoublePubSubType::getKey( +bool MapUShortLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6747,35 +6300,27 @@ bool MapUShortLongDoublePubSubType::getKey( const MapUShortLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6788,49 +6333,42 @@ void MapUShortLongDoublePubSubType::register_type_object_representation() MapUShortBooleanPubSubType::MapUShortBooleanPubSubType() { - setName("MapUShortBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortBoolean::getMaxCdrSerializedSize()); -#else - MapUShortBoolean_max_cdr_typesize; -#endif + set_name("MapUShortBoolean"); + uint32_t type_size = MapUShortBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortBoolean_max_key_cdr_typesize > 16 ? MapUShortBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortBoolean_max_key_cdr_typesize > 16 ? MapUShortBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortBooleanPubSubType::~MapUShortBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6845,16 +6383,12 @@ bool MapUShortBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6863,18 +6397,14 @@ bool MapUShortBooleanPubSubType::deserialize( MapUShortBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6887,52 +6417,62 @@ bool MapUShortBooleanPubSubType::deserialize( return true; } -std::function MapUShortBooleanPubSubType::getSerializedSizeProvider( +uint32_t MapUShortBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortBooleanPubSubType::createData() +void* MapUShortBooleanPubSubType::create_data() { return reinterpret_cast(new MapUShortBoolean()); } -void MapUShortBooleanPubSubType::deleteData( +void MapUShortBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortBooleanPubSubType::getKey( +bool MapUShortBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6940,35 +6480,27 @@ bool MapUShortBooleanPubSubType::getKey( const MapUShortBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6981,49 +6513,42 @@ void MapUShortBooleanPubSubType::register_type_object_representation() MapUShortOctetPubSubType::MapUShortOctetPubSubType() { - setName("MapUShortOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortOctet::getMaxCdrSerializedSize()); -#else - MapUShortOctet_max_cdr_typesize; -#endif + set_name("MapUShortOctet"); + uint32_t type_size = MapUShortOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortOctet_max_key_cdr_typesize > 16 ? MapUShortOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortOctet_max_key_cdr_typesize > 16 ? MapUShortOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortOctetPubSubType::~MapUShortOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7038,16 +6563,12 @@ bool MapUShortOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7056,18 +6577,14 @@ bool MapUShortOctetPubSubType::deserialize( MapUShortOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7080,52 +6597,62 @@ bool MapUShortOctetPubSubType::deserialize( return true; } -std::function MapUShortOctetPubSubType::getSerializedSizeProvider( +uint32_t MapUShortOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortOctetPubSubType::createData() +void* MapUShortOctetPubSubType::create_data() { return reinterpret_cast(new MapUShortOctet()); } -void MapUShortOctetPubSubType::deleteData( +void MapUShortOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortOctetPubSubType::getKey( +bool MapUShortOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7133,35 +6660,27 @@ bool MapUShortOctetPubSubType::getKey( const MapUShortOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7174,49 +6693,42 @@ void MapUShortOctetPubSubType::register_type_object_representation() MapUShortCharPubSubType::MapUShortCharPubSubType() { - setName("MapUShortChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortChar::getMaxCdrSerializedSize()); -#else - MapUShortChar_max_cdr_typesize; -#endif + set_name("MapUShortChar"); + uint32_t type_size = MapUShortChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortChar_max_key_cdr_typesize > 16 ? MapUShortChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortChar_max_key_cdr_typesize > 16 ? MapUShortChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortCharPubSubType::~MapUShortCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7231,16 +6743,12 @@ bool MapUShortCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7249,18 +6757,14 @@ bool MapUShortCharPubSubType::deserialize( MapUShortChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7273,52 +6777,62 @@ bool MapUShortCharPubSubType::deserialize( return true; } -std::function MapUShortCharPubSubType::getSerializedSizeProvider( +uint32_t MapUShortCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortCharPubSubType::createData() +void* MapUShortCharPubSubType::create_data() { return reinterpret_cast(new MapUShortChar()); } -void MapUShortCharPubSubType::deleteData( +void MapUShortCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortCharPubSubType::getKey( +bool MapUShortCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7326,35 +6840,27 @@ bool MapUShortCharPubSubType::getKey( const MapUShortChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7367,49 +6873,42 @@ void MapUShortCharPubSubType::register_type_object_representation() MapUShortWCharPubSubType::MapUShortWCharPubSubType() { - setName("MapUShortWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortWChar::getMaxCdrSerializedSize()); -#else - MapUShortWChar_max_cdr_typesize; -#endif + set_name("MapUShortWChar"); + uint32_t type_size = MapUShortWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortWChar_max_key_cdr_typesize > 16 ? MapUShortWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortWChar_max_key_cdr_typesize > 16 ? MapUShortWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortWCharPubSubType::~MapUShortWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7424,16 +6923,12 @@ bool MapUShortWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7442,18 +6937,14 @@ bool MapUShortWCharPubSubType::deserialize( MapUShortWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7466,52 +6957,62 @@ bool MapUShortWCharPubSubType::deserialize( return true; } -std::function MapUShortWCharPubSubType::getSerializedSizeProvider( +uint32_t MapUShortWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortWCharPubSubType::createData() +void* MapUShortWCharPubSubType::create_data() { return reinterpret_cast(new MapUShortWChar()); } -void MapUShortWCharPubSubType::deleteData( +void MapUShortWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortWCharPubSubType::getKey( +bool MapUShortWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7519,35 +7020,27 @@ bool MapUShortWCharPubSubType::getKey( const MapUShortWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7560,49 +7053,42 @@ void MapUShortWCharPubSubType::register_type_object_representation() MapUShortStringPubSubType::MapUShortStringPubSubType() { - setName("MapUShortString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortString::getMaxCdrSerializedSize()); -#else - MapUShortString_max_cdr_typesize; -#endif + set_name("MapUShortString"); + uint32_t type_size = MapUShortString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortString_max_key_cdr_typesize > 16 ? MapUShortString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortString_max_key_cdr_typesize > 16 ? MapUShortString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortStringPubSubType::~MapUShortStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7617,16 +7103,12 @@ bool MapUShortStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7635,18 +7117,14 @@ bool MapUShortStringPubSubType::deserialize( MapUShortString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7659,336 +7137,138 @@ bool MapUShortStringPubSubType::deserialize( return true; } -std::function MapUShortStringPubSubType::getSerializedSizeProvider( +uint32_t MapUShortStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapUShortStringPubSubType::createData() -{ - return reinterpret_cast(new MapUShortString()); -} - -void MapUShortStringPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapUShortStringPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapUShortString* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapUShortString_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapUShortString_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapUShortStringPubSubType::register_type_object_representation() -{ - register_MapUShortString_type_identifier(type_identifiers_); } -MapUShortWStringPubSubType::MapUShortWStringPubSubType() +void* MapUShortStringPubSubType::create_data() { - setName("MapUShortWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortWString::getMaxCdrSerializedSize()); -#else - MapUShortWString_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortWString_max_key_cdr_typesize > 16 ? MapUShortWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapUShortString()); } -MapUShortWStringPubSubType::~MapUShortWStringPubSubType() +void MapUShortStringPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapUShortWStringPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapUShortStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapUShortWString* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapUShortWStringPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapUShortWString* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapUShortString data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapUShortWStringPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapUShortWStringPubSubType::createData() -{ - return reinterpret_cast(new MapUShortWString()); -} - -void MapUShortWStringPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapUShortWStringPubSubType::getKey( +bool MapUShortStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapUShortWString* p_type = static_cast(data); + const MapUShortString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapUShortWString_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapUShortString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapUShortWString_max_key_cdr_typesize > 16) + if (force_md5 || MapUShortString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapUShortWStringPubSubType::register_type_object_representation() +void MapUShortStringPubSubType::register_type_object_representation() { - register_MapUShortWString_type_identifier(type_identifiers_); + register_MapUShortString_type_identifier(type_identifiers_); } -MapUShortInnerAliasBoundedStringHelperPubSubType::MapUShortInnerAliasBoundedStringHelperPubSubType() +MapUShortWStringPubSubType::MapUShortWStringPubSubType() { - setName("MapUShortInnerAliasBoundedStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerAliasBoundedStringHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerAliasBoundedStringHelper_max_cdr_typesize; -#endif + set_name("MapUShortWString"); + uint32_t type_size = MapUShortWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortWString_max_key_cdr_typesize > 16 ? MapUShortWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapUShortInnerAliasBoundedStringHelperPubSubType::~MapUShortInnerAliasBoundedStringHelperPubSubType() +MapUShortWStringPubSubType::~MapUShortWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapUShortInnerAliasBoundedStringHelperPubSubType::serialize( +bool MapUShortWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapUShortInnerAliasBoundedStringHelper* p_type = static_cast(data); + const MapUShortWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8003,16 +7283,192 @@ bool MapUShortInnerAliasBoundedStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapUShortWStringPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapUShortWString* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapUShortWStringPubSubType::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* MapUShortWStringPubSubType::create_data() +{ + return reinterpret_cast(new MapUShortWString()); +} + +void MapUShortWStringPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapUShortWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortWStringPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapUShortWString* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapUShortWString_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapUShortWString_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 MapUShortWStringPubSubType::register_type_object_representation() +{ + register_MapUShortWString_type_identifier(type_identifiers_); +} + +MapUShortInnerAliasBoundedStringHelperPubSubType::MapUShortInnerAliasBoundedStringHelperPubSubType() +{ + set_name("MapUShortInnerAliasBoundedStringHelper"); + uint32_t type_size = MapUShortInnerAliasBoundedStringHelper_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 = MapUShortInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapUShortInnerAliasBoundedStringHelperPubSubType::~MapUShortInnerAliasBoundedStringHelperPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapUShortInnerAliasBoundedStringHelperPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapUShortInnerAliasBoundedStringHelper* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerAliasBoundedStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8021,18 +7477,14 @@ bool MapUShortInnerAliasBoundedStringHelperPubSubType::deserialize( MapUShortInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8045,52 +7497,62 @@ bool MapUShortInnerAliasBoundedStringHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerAliasBoundedStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerAliasBoundedStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerAliasBoundedStringHelperPubSubType::createData() +void* MapUShortInnerAliasBoundedStringHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerAliasBoundedStringHelper()); } -void MapUShortInnerAliasBoundedStringHelperPubSubType::deleteData( +void MapUShortInnerAliasBoundedStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerAliasBoundedStringHelperPubSubType::getKey( +bool MapUShortInnerAliasBoundedStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerAliasBoundedStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerAliasBoundedStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8098,35 +7560,27 @@ bool MapUShortInnerAliasBoundedStringHelperPubSubType::getKey( const MapUShortInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerAliasBoundedStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8139,49 +7593,42 @@ void MapUShortInnerAliasBoundedStringHelperPubSubType::register_type_object_repr MapUShortInnerAliasBoundedWStringHelperPubSubType::MapUShortInnerAliasBoundedWStringHelperPubSubType() { - setName("MapUShortInnerAliasBoundedWStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerAliasBoundedWStringHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerAliasBoundedWStringHelper_max_cdr_typesize; -#endif + set_name("MapUShortInnerAliasBoundedWStringHelper"); + uint32_t type_size = MapUShortInnerAliasBoundedWStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortInnerAliasBoundedWStringHelperPubSubType::~MapUShortInnerAliasBoundedWStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortInnerAliasBoundedWStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8196,16 +7643,12 @@ bool MapUShortInnerAliasBoundedWStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerAliasBoundedWStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8214,18 +7657,14 @@ bool MapUShortInnerAliasBoundedWStringHelperPubSubType::deserialize( MapUShortInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8238,52 +7677,62 @@ bool MapUShortInnerAliasBoundedWStringHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerAliasBoundedWStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerAliasBoundedWStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerAliasBoundedWStringHelperPubSubType::createData() +void* MapUShortInnerAliasBoundedWStringHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerAliasBoundedWStringHelper()); } -void MapUShortInnerAliasBoundedWStringHelperPubSubType::deleteData( +void MapUShortInnerAliasBoundedWStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerAliasBoundedWStringHelperPubSubType::getKey( +bool MapUShortInnerAliasBoundedWStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerAliasBoundedWStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerAliasBoundedWStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8291,35 +7740,27 @@ bool MapUShortInnerAliasBoundedWStringHelperPubSubType::getKey( const MapUShortInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8332,49 +7773,42 @@ void MapUShortInnerAliasBoundedWStringHelperPubSubType::register_type_object_rep MapUShortInnerEnumHelperPubSubType::MapUShortInnerEnumHelperPubSubType() { - setName("MapUShortInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerEnumHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerEnumHelper_max_cdr_typesize; -#endif + set_name("MapUShortInnerEnumHelper"); + uint32_t type_size = MapUShortInnerEnumHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerEnumHelper_max_key_cdr_typesize > 16 ? MapUShortInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortInnerEnumHelper_max_key_cdr_typesize > 16 ? MapUShortInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortInnerEnumHelperPubSubType::~MapUShortInnerEnumHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortInnerEnumHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8389,16 +7823,12 @@ bool MapUShortInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8407,18 +7837,14 @@ bool MapUShortInnerEnumHelperPubSubType::deserialize( MapUShortInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8431,52 +7857,62 @@ bool MapUShortInnerEnumHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerEnumHelperPubSubType::createData() +void* MapUShortInnerEnumHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerEnumHelper()); } -void MapUShortInnerEnumHelperPubSubType::deleteData( +void MapUShortInnerEnumHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerEnumHelperPubSubType::getKey( +bool MapUShortInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8484,35 +7920,27 @@ bool MapUShortInnerEnumHelperPubSubType::getKey( const MapUShortInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8525,49 +7953,42 @@ void MapUShortInnerEnumHelperPubSubType::register_type_object_representation() MapUShortInnerBitMaskHelperPubSubType::MapUShortInnerBitMaskHelperPubSubType() { - setName("MapUShortInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerBitMaskHelper_max_cdr_typesize; -#endif + set_name("MapUShortInnerBitMaskHelper"); + uint32_t type_size = MapUShortInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapUShortInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapUShortInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortInnerBitMaskHelperPubSubType::~MapUShortInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8582,16 +8003,12 @@ bool MapUShortInnerBitMaskHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8600,18 +8017,14 @@ bool MapUShortInnerBitMaskHelperPubSubType::deserialize( MapUShortInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8624,52 +8037,62 @@ bool MapUShortInnerBitMaskHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerBitMaskHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerBitMaskHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerBitMaskHelperPubSubType::createData() +void* MapUShortInnerBitMaskHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerBitMaskHelper()); } -void MapUShortInnerBitMaskHelperPubSubType::deleteData( +void MapUShortInnerBitMaskHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerBitMaskHelperPubSubType::getKey( +bool MapUShortInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerBitMaskHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8677,35 +8100,27 @@ bool MapUShortInnerBitMaskHelperPubSubType::getKey( const MapUShortInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerBitMaskHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerBitMaskHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8718,49 +8133,42 @@ void MapUShortInnerBitMaskHelperPubSubType::register_type_object_representation( MapUShortInnerAliasHelperPubSubType::MapUShortInnerAliasHelperPubSubType() { - setName("MapUShortInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerAliasHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerAliasHelper_max_cdr_typesize; -#endif + set_name("MapUShortInnerAliasHelper"); + uint32_t type_size = MapUShortInnerAliasHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerAliasHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortInnerAliasHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortInnerAliasHelperPubSubType::~MapUShortInnerAliasHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortInnerAliasHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8775,16 +8183,12 @@ bool MapUShortInnerAliasHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8793,18 +8197,14 @@ bool MapUShortInnerAliasHelperPubSubType::deserialize( MapUShortInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8817,52 +8217,62 @@ bool MapUShortInnerAliasHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerAliasHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerAliasHelperPubSubType::createData() +void* MapUShortInnerAliasHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerAliasHelper()); } -void MapUShortInnerAliasHelperPubSubType::deleteData( +void MapUShortInnerAliasHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerAliasHelperPubSubType::getKey( +bool MapUShortInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8870,35 +8280,27 @@ bool MapUShortInnerAliasHelperPubSubType::getKey( const MapUShortInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8911,49 +8313,42 @@ void MapUShortInnerAliasHelperPubSubType::register_type_object_representation() MapUShortInnerAliasArrayHelperPubSubType::MapUShortInnerAliasArrayHelperPubSubType() { - setName("MapUShortInnerAliasArrayHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerAliasArrayHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerAliasArrayHelper_max_cdr_typesize; -#endif + set_name("MapUShortInnerAliasArrayHelper"); + uint32_t type_size = MapUShortInnerAliasArrayHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasArrayHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasArrayHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortInnerAliasArrayHelperPubSubType::~MapUShortInnerAliasArrayHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortInnerAliasArrayHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8968,16 +8363,12 @@ bool MapUShortInnerAliasArrayHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerAliasArrayHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8986,18 +8377,14 @@ bool MapUShortInnerAliasArrayHelperPubSubType::deserialize( MapUShortInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9010,52 +8397,62 @@ bool MapUShortInnerAliasArrayHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerAliasArrayHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerAliasArrayHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerAliasArrayHelperPubSubType::createData() +void* MapUShortInnerAliasArrayHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerAliasArrayHelper()); } -void MapUShortInnerAliasArrayHelperPubSubType::deleteData( +void MapUShortInnerAliasArrayHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerAliasArrayHelperPubSubType::getKey( +bool MapUShortInnerAliasArrayHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerAliasArrayHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerAliasArrayHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9063,35 +8460,27 @@ bool MapUShortInnerAliasArrayHelperPubSubType::getKey( const MapUShortInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerAliasArrayHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerAliasArrayHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9104,49 +8493,42 @@ void MapUShortInnerAliasArrayHelperPubSubType::register_type_object_representati MapUShortInnerAliasSequenceHelperPubSubType::MapUShortInnerAliasSequenceHelperPubSubType() { - setName("MapUShortInnerAliasSequenceHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerAliasSequenceHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerAliasSequenceHelper_max_cdr_typesize; -#endif + set_name("MapUShortInnerAliasSequenceHelper"); + uint32_t type_size = MapUShortInnerAliasSequenceHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasSequenceHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasSequenceHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortInnerAliasSequenceHelperPubSubType::~MapUShortInnerAliasSequenceHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortInnerAliasSequenceHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9161,16 +8543,12 @@ bool MapUShortInnerAliasSequenceHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerAliasSequenceHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9179,18 +8557,14 @@ bool MapUShortInnerAliasSequenceHelperPubSubType::deserialize( MapUShortInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9203,52 +8577,62 @@ bool MapUShortInnerAliasSequenceHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerAliasSequenceHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerAliasSequenceHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerAliasSequenceHelperPubSubType::createData() +void* MapUShortInnerAliasSequenceHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerAliasSequenceHelper()); } -void MapUShortInnerAliasSequenceHelperPubSubType::deleteData( +void MapUShortInnerAliasSequenceHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerAliasSequenceHelperPubSubType::getKey( +bool MapUShortInnerAliasSequenceHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerAliasSequenceHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerAliasSequenceHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9256,35 +8640,27 @@ bool MapUShortInnerAliasSequenceHelperPubSubType::getKey( const MapUShortInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerAliasSequenceHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerAliasSequenceHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9297,49 +8673,42 @@ void MapUShortInnerAliasSequenceHelperPubSubType::register_type_object_represent MapUShortInnerAliasMapHelperPubSubType::MapUShortInnerAliasMapHelperPubSubType() { - setName("MapUShortInnerAliasMapHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerAliasMapHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerAliasMapHelper_max_cdr_typesize; -#endif + set_name("MapUShortInnerAliasMapHelper"); + uint32_t type_size = MapUShortInnerAliasMapHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasMapHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapUShortInnerAliasMapHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortInnerAliasMapHelperPubSubType::~MapUShortInnerAliasMapHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortInnerAliasMapHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9354,16 +8723,12 @@ bool MapUShortInnerAliasMapHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerAliasMapHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9372,18 +8737,14 @@ bool MapUShortInnerAliasMapHelperPubSubType::deserialize( MapUShortInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9396,52 +8757,62 @@ bool MapUShortInnerAliasMapHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerAliasMapHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerAliasMapHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerAliasMapHelperPubSubType::createData() +void* MapUShortInnerAliasMapHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerAliasMapHelper()); } -void MapUShortInnerAliasMapHelperPubSubType::deleteData( +void MapUShortInnerAliasMapHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerAliasMapHelperPubSubType::getKey( +bool MapUShortInnerAliasMapHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerAliasMapHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerAliasMapHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9449,35 +8820,27 @@ bool MapUShortInnerAliasMapHelperPubSubType::getKey( const MapUShortInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerAliasMapHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerAliasMapHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9490,49 +8853,42 @@ void MapUShortInnerAliasMapHelperPubSubType::register_type_object_representation MapUShortInnerUnionHelperPubSubType::MapUShortInnerUnionHelperPubSubType() { - setName("MapUShortInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerUnionHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerUnionHelper_max_cdr_typesize; -#endif + set_name("MapUShortInnerUnionHelper"); + uint32_t type_size = MapUShortInnerUnionHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerUnionHelper_max_key_cdr_typesize > 16 ? MapUShortInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortInnerUnionHelper_max_key_cdr_typesize > 16 ? MapUShortInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortInnerUnionHelperPubSubType::~MapUShortInnerUnionHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortInnerUnionHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9547,16 +8903,12 @@ bool MapUShortInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9565,18 +8917,14 @@ bool MapUShortInnerUnionHelperPubSubType::deserialize( MapUShortInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9589,52 +8937,62 @@ bool MapUShortInnerUnionHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerUnionHelperPubSubType::createData() +void* MapUShortInnerUnionHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerUnionHelper()); } -void MapUShortInnerUnionHelperPubSubType::deleteData( +void MapUShortInnerUnionHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerUnionHelperPubSubType::getKey( +bool MapUShortInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9642,35 +9000,27 @@ bool MapUShortInnerUnionHelperPubSubType::getKey( const MapUShortInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9683,49 +9033,42 @@ void MapUShortInnerUnionHelperPubSubType::register_type_object_representation() MapUShortInnerStructureHelperPubSubType::MapUShortInnerStructureHelperPubSubType() { - setName("MapUShortInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerStructureHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerStructureHelper_max_cdr_typesize; -#endif + set_name("MapUShortInnerStructureHelper"); + uint32_t type_size = MapUShortInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerStructureHelper_max_key_cdr_typesize > 16 ? MapUShortInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortInnerStructureHelper_max_key_cdr_typesize > 16 ? MapUShortInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortInnerStructureHelperPubSubType::~MapUShortInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9740,16 +9083,12 @@ bool MapUShortInnerStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9758,18 +9097,14 @@ bool MapUShortInnerStructureHelperPubSubType::deserialize( MapUShortInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9782,52 +9117,62 @@ bool MapUShortInnerStructureHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerStructureHelperPubSubType::createData() +void* MapUShortInnerStructureHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerStructureHelper()); } -void MapUShortInnerStructureHelperPubSubType::deleteData( +void MapUShortInnerStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerStructureHelperPubSubType::getKey( +bool MapUShortInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9835,35 +9180,27 @@ bool MapUShortInnerStructureHelperPubSubType::getKey( const MapUShortInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9876,49 +9213,42 @@ void MapUShortInnerStructureHelperPubSubType::register_type_object_representatio MapUShortInnerBitsetHelperPubSubType::MapUShortInnerBitsetHelperPubSubType() { - setName("MapUShortInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapUShortInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - MapUShortInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("MapUShortInnerBitsetHelper"); + uint32_t type_size = MapUShortInnerBitsetHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapUShortInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapUShortInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapUShortInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapUShortInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapUShortInnerBitsetHelperPubSubType::~MapUShortInnerBitsetHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapUShortInnerBitsetHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapUShortInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9933,16 +9263,12 @@ bool MapUShortInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapUShortInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9951,18 +9277,14 @@ bool MapUShortInnerBitsetHelperPubSubType::deserialize( MapUShortInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9975,52 +9297,62 @@ bool MapUShortInnerBitsetHelperPubSubType::deserialize( return true; } -std::function MapUShortInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t MapUShortInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapUShortInnerBitsetHelperPubSubType::createData() +void* MapUShortInnerBitsetHelperPubSubType::create_data() { return reinterpret_cast(new MapUShortInnerBitsetHelper()); } -void MapUShortInnerBitsetHelperPubSubType::deleteData( +void MapUShortInnerBitsetHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapUShortInnerBitsetHelperPubSubType::getKey( +bool MapUShortInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapUShortInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapUShortInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10028,35 +9360,27 @@ bool MapUShortInnerBitsetHelperPubSubType::getKey( const MapUShortInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapUShortInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapUShortInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10069,49 +9393,42 @@ void MapUShortInnerBitsetHelperPubSubType::register_type_object_representation() MapLongShortPubSubType::MapLongShortPubSubType() { - setName("MapLongShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongShort::getMaxCdrSerializedSize()); -#else - MapLongShort_max_cdr_typesize; -#endif + set_name("MapLongShort"); + uint32_t type_size = MapLongShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongShort_max_key_cdr_typesize > 16 ? MapLongShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongShort_max_key_cdr_typesize > 16 ? MapLongShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongShortPubSubType::~MapLongShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10126,16 +9443,12 @@ bool MapLongShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10144,18 +9457,14 @@ bool MapLongShortPubSubType::deserialize( MapLongShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10168,52 +9477,62 @@ bool MapLongShortPubSubType::deserialize( return true; } -std::function MapLongShortPubSubType::getSerializedSizeProvider( +uint32_t MapLongShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongShortPubSubType::createData() +void* MapLongShortPubSubType::create_data() { return reinterpret_cast(new MapLongShort()); } -void MapLongShortPubSubType::deleteData( +void MapLongShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongShortPubSubType::getKey( +bool MapLongShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10221,35 +9540,27 @@ bool MapLongShortPubSubType::getKey( const MapLongShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10262,49 +9573,42 @@ void MapLongShortPubSubType::register_type_object_representation() MapLongUShortPubSubType::MapLongUShortPubSubType() { - setName("MapLongUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongUShort::getMaxCdrSerializedSize()); -#else - MapLongUShort_max_cdr_typesize; -#endif + set_name("MapLongUShort"); + uint32_t type_size = MapLongUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongUShort_max_key_cdr_typesize > 16 ? MapLongUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongUShort_max_key_cdr_typesize > 16 ? MapLongUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongUShortPubSubType::~MapLongUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10319,16 +9623,12 @@ bool MapLongUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10337,18 +9637,14 @@ bool MapLongUShortPubSubType::deserialize( MapLongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10361,52 +9657,62 @@ bool MapLongUShortPubSubType::deserialize( return true; } -std::function MapLongUShortPubSubType::getSerializedSizeProvider( +uint32_t MapLongUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongUShortPubSubType::createData() +void* MapLongUShortPubSubType::create_data() { return reinterpret_cast(new MapLongUShort()); } -void MapLongUShortPubSubType::deleteData( +void MapLongUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongUShortPubSubType::getKey( +bool MapLongUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10414,35 +9720,27 @@ bool MapLongUShortPubSubType::getKey( const MapLongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10455,49 +9753,42 @@ void MapLongUShortPubSubType::register_type_object_representation() MapLongLongPubSubType::MapLongLongPubSubType() { - setName("MapLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLong::getMaxCdrSerializedSize()); -#else - MapLongLong_max_cdr_typesize; -#endif + set_name("MapLongLong"); + uint32_t type_size = MapLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLong_max_key_cdr_typesize > 16 ? MapLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLong_max_key_cdr_typesize > 16 ? MapLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongPubSubType::~MapLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10512,16 +9803,12 @@ bool MapLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10530,18 +9817,14 @@ bool MapLongLongPubSubType::deserialize( MapLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10554,52 +9837,62 @@ bool MapLongLongPubSubType::deserialize( return true; } -std::function MapLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongPubSubType::createData() +void* MapLongLongPubSubType::create_data() { return reinterpret_cast(new MapLongLong()); } -void MapLongLongPubSubType::deleteData( +void MapLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongPubSubType::getKey( +bool MapLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10607,35 +9900,27 @@ bool MapLongLongPubSubType::getKey( const MapLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10648,49 +9933,42 @@ void MapLongLongPubSubType::register_type_object_representation() MapLongULongPubSubType::MapLongULongPubSubType() { - setName("MapLongULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongULong::getMaxCdrSerializedSize()); -#else - MapLongULong_max_cdr_typesize; -#endif + set_name("MapLongULong"); + uint32_t type_size = MapLongULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongULong_max_key_cdr_typesize > 16 ? MapLongULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongULong_max_key_cdr_typesize > 16 ? MapLongULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongULongPubSubType::~MapLongULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10705,16 +9983,12 @@ bool MapLongULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10723,18 +9997,14 @@ bool MapLongULongPubSubType::deserialize( MapLongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10747,336 +10017,138 @@ bool MapLongULongPubSubType::deserialize( return true; } -std::function MapLongULongPubSubType::getSerializedSizeProvider( +uint32_t MapLongULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapLongULongPubSubType::createData() -{ - return reinterpret_cast(new MapLongULong()); -} - -void MapLongULongPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapLongULongPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapLongULong* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapLongULong_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapLongULong_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapLongULongPubSubType::register_type_object_representation() -{ - register_MapLongULong_type_identifier(type_identifiers_); } -MapLongKeyLongLongValuePubSubType::MapLongKeyLongLongValuePubSubType() +void* MapLongULongPubSubType::create_data() { - setName("MapLongKeyLongLongValue"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongKeyLongLongValue::getMaxCdrSerializedSize()); -#else - MapLongKeyLongLongValue_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongKeyLongLongValue_max_key_cdr_typesize > 16 ? MapLongKeyLongLongValue_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapLongULong()); } -MapLongKeyLongLongValuePubSubType::~MapLongKeyLongLongValuePubSubType() +void MapLongULongPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapLongKeyLongLongValuePubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapLongULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapLongKeyLongLongValue* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapLongKeyLongLongValuePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapLongKeyLongLongValue* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapLongULong data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapLongKeyLongLongValuePubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapLongKeyLongLongValuePubSubType::createData() -{ - return reinterpret_cast(new MapLongKeyLongLongValue()); -} - -void MapLongKeyLongLongValuePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapLongKeyLongLongValuePubSubType::getKey( +bool MapLongULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapLongKeyLongLongValue* p_type = static_cast(data); + const MapLongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapLongKeyLongLongValue_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapLongULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapLongKeyLongLongValue_max_key_cdr_typesize > 16) + if (force_md5 || MapLongULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapLongKeyLongLongValuePubSubType::register_type_object_representation() +void MapLongULongPubSubType::register_type_object_representation() { - register_MapLongKeyLongLongValue_type_identifier(type_identifiers_); + register_MapLongULong_type_identifier(type_identifiers_); } -MapLongULongLongPubSubType::MapLongULongLongPubSubType() +MapLongKeyLongLongValuePubSubType::MapLongKeyLongLongValuePubSubType() { - setName("MapLongULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongULongLong::getMaxCdrSerializedSize()); -#else - MapLongULongLong_max_cdr_typesize; -#endif + set_name("MapLongKeyLongLongValue"); + uint32_t type_size = MapLongKeyLongLongValue_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongULongLong_max_key_cdr_typesize > 16 ? MapLongULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongKeyLongLongValue_max_key_cdr_typesize > 16 ? MapLongKeyLongLongValue_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapLongULongLongPubSubType::~MapLongULongLongPubSubType() +MapLongKeyLongLongValuePubSubType::~MapLongKeyLongLongValuePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapLongULongLongPubSubType::serialize( +bool MapLongKeyLongLongValuePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapLongULongLong* p_type = static_cast(data); + const MapLongKeyLongLongValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11091,16 +10163,192 @@ bool MapLongULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapLongKeyLongLongValuePubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapLongKeyLongLongValue* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapLongKeyLongLongValuePubSubType::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* MapLongKeyLongLongValuePubSubType::create_data() +{ + return reinterpret_cast(new MapLongKeyLongLongValue()); +} + +void MapLongKeyLongLongValuePubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapLongKeyLongLongValuePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongKeyLongLongValue data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongKeyLongLongValuePubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapLongKeyLongLongValue* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapLongKeyLongLongValue_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapLongKeyLongLongValue_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 MapLongKeyLongLongValuePubSubType::register_type_object_representation() +{ + register_MapLongKeyLongLongValue_type_identifier(type_identifiers_); +} + +MapLongULongLongPubSubType::MapLongULongLongPubSubType() +{ + set_name("MapLongULongLong"); + uint32_t type_size = MapLongULongLong_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 = MapLongULongLong_max_key_cdr_typesize > 16 ? MapLongULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapLongULongLongPubSubType::~MapLongULongLongPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapLongULongLongPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapLongULongLong* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11109,18 +10357,14 @@ bool MapLongULongLongPubSubType::deserialize( MapLongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11133,52 +10377,62 @@ bool MapLongULongLongPubSubType::deserialize( return true; } -std::function MapLongULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapLongULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongULongLongPubSubType::createData() +void* MapLongULongLongPubSubType::create_data() { return reinterpret_cast(new MapLongULongLong()); } -void MapLongULongLongPubSubType::deleteData( +void MapLongULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongULongLongPubSubType::getKey( +bool MapLongULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11186,35 +10440,27 @@ bool MapLongULongLongPubSubType::getKey( const MapLongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11227,49 +10473,42 @@ void MapLongULongLongPubSubType::register_type_object_representation() MapLongFloatPubSubType::MapLongFloatPubSubType() { - setName("MapLongFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongFloat::getMaxCdrSerializedSize()); -#else - MapLongFloat_max_cdr_typesize; -#endif + set_name("MapLongFloat"); + uint32_t type_size = MapLongFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongFloat_max_key_cdr_typesize > 16 ? MapLongFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongFloat_max_key_cdr_typesize > 16 ? MapLongFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongFloatPubSubType::~MapLongFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11284,16 +10523,12 @@ bool MapLongFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11302,18 +10537,14 @@ bool MapLongFloatPubSubType::deserialize( MapLongFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11326,52 +10557,62 @@ bool MapLongFloatPubSubType::deserialize( return true; } -std::function MapLongFloatPubSubType::getSerializedSizeProvider( +uint32_t MapLongFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongFloatPubSubType::createData() +void* MapLongFloatPubSubType::create_data() { return reinterpret_cast(new MapLongFloat()); } -void MapLongFloatPubSubType::deleteData( +void MapLongFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongFloatPubSubType::getKey( +bool MapLongFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11379,35 +10620,27 @@ bool MapLongFloatPubSubType::getKey( const MapLongFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11420,49 +10653,42 @@ void MapLongFloatPubSubType::register_type_object_representation() MapLongDoublePubSubType::MapLongDoublePubSubType() { - setName("MapLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongDouble::getMaxCdrSerializedSize()); -#else - MapLongDouble_max_cdr_typesize; -#endif + set_name("MapLongDouble"); + uint32_t type_size = MapLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongDouble_max_key_cdr_typesize > 16 ? MapLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongDouble_max_key_cdr_typesize > 16 ? MapLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongDoublePubSubType::~MapLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11477,16 +10703,12 @@ bool MapLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11495,18 +10717,14 @@ bool MapLongDoublePubSubType::deserialize( MapLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11519,52 +10737,62 @@ bool MapLongDoublePubSubType::deserialize( return true; } -std::function MapLongDoublePubSubType::getSerializedSizeProvider( +uint32_t MapLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongDoublePubSubType::createData() +void* MapLongDoublePubSubType::create_data() { return reinterpret_cast(new MapLongDouble()); } -void MapLongDoublePubSubType::deleteData( +void MapLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongDoublePubSubType::getKey( +bool MapLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11572,35 +10800,27 @@ bool MapLongDoublePubSubType::getKey( const MapLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11613,49 +10833,42 @@ void MapLongDoublePubSubType::register_type_object_representation() MapLongKeyLongDoubleValuePubSubType::MapLongKeyLongDoubleValuePubSubType() { - setName("MapLongKeyLongDoubleValue"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongKeyLongDoubleValue::getMaxCdrSerializedSize()); -#else - MapLongKeyLongDoubleValue_max_cdr_typesize; -#endif + set_name("MapLongKeyLongDoubleValue"); + uint32_t type_size = MapLongKeyLongDoubleValue_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongKeyLongDoubleValue_max_key_cdr_typesize > 16 ? MapLongKeyLongDoubleValue_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongKeyLongDoubleValue_max_key_cdr_typesize > 16 ? MapLongKeyLongDoubleValue_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongKeyLongDoubleValuePubSubType::~MapLongKeyLongDoubleValuePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongKeyLongDoubleValuePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongKeyLongDoubleValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11670,16 +10883,12 @@ bool MapLongKeyLongDoubleValuePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongKeyLongDoubleValuePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11688,18 +10897,14 @@ bool MapLongKeyLongDoubleValuePubSubType::deserialize( MapLongKeyLongDoubleValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11712,52 +10917,62 @@ bool MapLongKeyLongDoubleValuePubSubType::deserialize( return true; } -std::function MapLongKeyLongDoubleValuePubSubType::getSerializedSizeProvider( +uint32_t MapLongKeyLongDoubleValuePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongKeyLongDoubleValuePubSubType::createData() +void* MapLongKeyLongDoubleValuePubSubType::create_data() { return reinterpret_cast(new MapLongKeyLongDoubleValue()); } -void MapLongKeyLongDoubleValuePubSubType::deleteData( +void MapLongKeyLongDoubleValuePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongKeyLongDoubleValuePubSubType::getKey( +bool MapLongKeyLongDoubleValuePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongKeyLongDoubleValue data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongKeyLongDoubleValuePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11765,35 +10980,27 @@ bool MapLongKeyLongDoubleValuePubSubType::getKey( const MapLongKeyLongDoubleValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongKeyLongDoubleValue_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongKeyLongDoubleValue_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11806,49 +11013,42 @@ void MapLongKeyLongDoubleValuePubSubType::register_type_object_representation() MapLongBooleanPubSubType::MapLongBooleanPubSubType() { - setName("MapLongBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongBoolean::getMaxCdrSerializedSize()); -#else - MapLongBoolean_max_cdr_typesize; -#endif + set_name("MapLongBoolean"); + uint32_t type_size = MapLongBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongBoolean_max_key_cdr_typesize > 16 ? MapLongBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongBoolean_max_key_cdr_typesize > 16 ? MapLongBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongBooleanPubSubType::~MapLongBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11863,16 +11063,12 @@ bool MapLongBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11881,18 +11077,14 @@ bool MapLongBooleanPubSubType::deserialize( MapLongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11905,52 +11097,62 @@ bool MapLongBooleanPubSubType::deserialize( return true; } -std::function MapLongBooleanPubSubType::getSerializedSizeProvider( +uint32_t MapLongBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongBooleanPubSubType::createData() +void* MapLongBooleanPubSubType::create_data() { return reinterpret_cast(new MapLongBoolean()); } -void MapLongBooleanPubSubType::deleteData( +void MapLongBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongBooleanPubSubType::getKey( +bool MapLongBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11958,35 +11160,27 @@ bool MapLongBooleanPubSubType::getKey( const MapLongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11999,49 +11193,42 @@ void MapLongBooleanPubSubType::register_type_object_representation() MapLongOctetPubSubType::MapLongOctetPubSubType() { - setName("MapLongOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongOctet::getMaxCdrSerializedSize()); -#else - MapLongOctet_max_cdr_typesize; -#endif + set_name("MapLongOctet"); + uint32_t type_size = MapLongOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongOctet_max_key_cdr_typesize > 16 ? MapLongOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongOctet_max_key_cdr_typesize > 16 ? MapLongOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongOctetPubSubType::~MapLongOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12056,16 +11243,12 @@ bool MapLongOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12074,18 +11257,14 @@ bool MapLongOctetPubSubType::deserialize( MapLongOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12098,52 +11277,62 @@ bool MapLongOctetPubSubType::deserialize( return true; } -std::function MapLongOctetPubSubType::getSerializedSizeProvider( +uint32_t MapLongOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongOctetPubSubType::createData() +void* MapLongOctetPubSubType::create_data() { return reinterpret_cast(new MapLongOctet()); } -void MapLongOctetPubSubType::deleteData( +void MapLongOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongOctetPubSubType::getKey( +bool MapLongOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12151,35 +11340,27 @@ bool MapLongOctetPubSubType::getKey( const MapLongOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12192,49 +11373,42 @@ void MapLongOctetPubSubType::register_type_object_representation() MapLongCharPubSubType::MapLongCharPubSubType() { - setName("MapLongChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongChar::getMaxCdrSerializedSize()); -#else - MapLongChar_max_cdr_typesize; -#endif + set_name("MapLongChar"); + uint32_t type_size = MapLongChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongChar_max_key_cdr_typesize > 16 ? MapLongChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongChar_max_key_cdr_typesize > 16 ? MapLongChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongCharPubSubType::~MapLongCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12249,16 +11423,12 @@ bool MapLongCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12267,18 +11437,14 @@ bool MapLongCharPubSubType::deserialize( MapLongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12291,52 +11457,62 @@ bool MapLongCharPubSubType::deserialize( return true; } -std::function MapLongCharPubSubType::getSerializedSizeProvider( +uint32_t MapLongCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongCharPubSubType::createData() +void* MapLongCharPubSubType::create_data() { return reinterpret_cast(new MapLongChar()); } -void MapLongCharPubSubType::deleteData( +void MapLongCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongCharPubSubType::getKey( +bool MapLongCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12344,35 +11520,27 @@ bool MapLongCharPubSubType::getKey( const MapLongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12385,49 +11553,42 @@ void MapLongCharPubSubType::register_type_object_representation() MapLongWCharPubSubType::MapLongWCharPubSubType() { - setName("MapLongWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongWChar::getMaxCdrSerializedSize()); -#else - MapLongWChar_max_cdr_typesize; -#endif + set_name("MapLongWChar"); + uint32_t type_size = MapLongWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongWChar_max_key_cdr_typesize > 16 ? MapLongWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongWChar_max_key_cdr_typesize > 16 ? MapLongWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongWCharPubSubType::~MapLongWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12442,16 +11603,12 @@ bool MapLongWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12460,18 +11617,14 @@ bool MapLongWCharPubSubType::deserialize( MapLongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12484,52 +11637,62 @@ bool MapLongWCharPubSubType::deserialize( return true; } -std::function MapLongWCharPubSubType::getSerializedSizeProvider( +uint32_t MapLongWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongWCharPubSubType::createData() +void* MapLongWCharPubSubType::create_data() { return reinterpret_cast(new MapLongWChar()); } -void MapLongWCharPubSubType::deleteData( +void MapLongWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongWCharPubSubType::getKey( +bool MapLongWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12537,35 +11700,27 @@ bool MapLongWCharPubSubType::getKey( const MapLongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12578,49 +11733,42 @@ void MapLongWCharPubSubType::register_type_object_representation() MapLongStringPubSubType::MapLongStringPubSubType() { - setName("MapLongString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongString::getMaxCdrSerializedSize()); -#else - MapLongString_max_cdr_typesize; -#endif + set_name("MapLongString"); + uint32_t type_size = MapLongString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongString_max_key_cdr_typesize > 16 ? MapLongString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongString_max_key_cdr_typesize > 16 ? MapLongString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongStringPubSubType::~MapLongStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12635,16 +11783,12 @@ bool MapLongStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12653,18 +11797,14 @@ bool MapLongStringPubSubType::deserialize( MapLongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12677,52 +11817,62 @@ bool MapLongStringPubSubType::deserialize( return true; } -std::function MapLongStringPubSubType::getSerializedSizeProvider( +uint32_t MapLongStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongStringPubSubType::createData() +void* MapLongStringPubSubType::create_data() { return reinterpret_cast(new MapLongString()); } -void MapLongStringPubSubType::deleteData( +void MapLongStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongStringPubSubType::getKey( +bool MapLongStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12730,35 +11880,27 @@ bool MapLongStringPubSubType::getKey( const MapLongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12771,49 +11913,42 @@ void MapLongStringPubSubType::register_type_object_representation() MapLongWStringPubSubType::MapLongWStringPubSubType() { - setName("MapLongWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongWString::getMaxCdrSerializedSize()); -#else - MapLongWString_max_cdr_typesize; -#endif + set_name("MapLongWString"); + uint32_t type_size = MapLongWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongWString_max_key_cdr_typesize > 16 ? MapLongWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongWString_max_key_cdr_typesize > 16 ? MapLongWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongWStringPubSubType::~MapLongWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12828,16 +11963,12 @@ bool MapLongWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12846,18 +11977,14 @@ bool MapLongWStringPubSubType::deserialize( MapLongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12870,52 +11997,62 @@ bool MapLongWStringPubSubType::deserialize( return true; } -std::function MapLongWStringPubSubType::getSerializedSizeProvider( +uint32_t MapLongWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongWStringPubSubType::createData() +void* MapLongWStringPubSubType::create_data() { return reinterpret_cast(new MapLongWString()); } -void MapLongWStringPubSubType::deleteData( +void MapLongWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongWStringPubSubType::getKey( +bool MapLongWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12923,35 +12060,27 @@ bool MapLongWStringPubSubType::getKey( const MapLongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12964,49 +12093,42 @@ void MapLongWStringPubSubType::register_type_object_representation() MapLongInnerAliasBoundedStringHelperPubSubType::MapLongInnerAliasBoundedStringHelperPubSubType() { - setName("MapLongInnerAliasBoundedStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerAliasBoundedStringHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerAliasBoundedStringHelper_max_cdr_typesize; -#endif + set_name("MapLongInnerAliasBoundedStringHelper"); + uint32_t type_size = MapLongInnerAliasBoundedStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongInnerAliasBoundedStringHelperPubSubType::~MapLongInnerAliasBoundedStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongInnerAliasBoundedStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13021,16 +12143,12 @@ bool MapLongInnerAliasBoundedStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongInnerAliasBoundedStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13039,18 +12157,14 @@ bool MapLongInnerAliasBoundedStringHelperPubSubType::deserialize( MapLongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13063,52 +12177,62 @@ bool MapLongInnerAliasBoundedStringHelperPubSubType::deserialize( return true; } -std::function MapLongInnerAliasBoundedStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongInnerAliasBoundedStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongInnerAliasBoundedStringHelperPubSubType::createData() +void* MapLongInnerAliasBoundedStringHelperPubSubType::create_data() { return reinterpret_cast(new MapLongInnerAliasBoundedStringHelper()); } -void MapLongInnerAliasBoundedStringHelperPubSubType::deleteData( +void MapLongInnerAliasBoundedStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongInnerAliasBoundedStringHelperPubSubType::getKey( +bool MapLongInnerAliasBoundedStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongInnerAliasBoundedStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongInnerAliasBoundedStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13116,35 +12240,27 @@ bool MapLongInnerAliasBoundedStringHelperPubSubType::getKey( const MapLongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongInnerAliasBoundedStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13157,49 +12273,42 @@ void MapLongInnerAliasBoundedStringHelperPubSubType::register_type_object_repres MapLongInnerAliasBoundedWStringHelperPubSubType::MapLongInnerAliasBoundedWStringHelperPubSubType() { - setName("MapLongInnerAliasBoundedWStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerAliasBoundedWStringHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerAliasBoundedWStringHelper_max_cdr_typesize; -#endif + set_name("MapLongInnerAliasBoundedWStringHelper"); + uint32_t type_size = MapLongInnerAliasBoundedWStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongInnerAliasBoundedWStringHelperPubSubType::~MapLongInnerAliasBoundedWStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongInnerAliasBoundedWStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13214,16 +12323,12 @@ bool MapLongInnerAliasBoundedWStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongInnerAliasBoundedWStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13232,18 +12337,14 @@ bool MapLongInnerAliasBoundedWStringHelperPubSubType::deserialize( MapLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13256,52 +12357,62 @@ bool MapLongInnerAliasBoundedWStringHelperPubSubType::deserialize( return true; } -std::function MapLongInnerAliasBoundedWStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongInnerAliasBoundedWStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongInnerAliasBoundedWStringHelperPubSubType::createData() +void* MapLongInnerAliasBoundedWStringHelperPubSubType::create_data() { return reinterpret_cast(new MapLongInnerAliasBoundedWStringHelper()); } -void MapLongInnerAliasBoundedWStringHelperPubSubType::deleteData( +void MapLongInnerAliasBoundedWStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongInnerAliasBoundedWStringHelperPubSubType::getKey( +bool MapLongInnerAliasBoundedWStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongInnerAliasBoundedWStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongInnerAliasBoundedWStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13309,35 +12420,27 @@ bool MapLongInnerAliasBoundedWStringHelperPubSubType::getKey( const MapLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13350,49 +12453,42 @@ void MapLongInnerAliasBoundedWStringHelperPubSubType::register_type_object_repre MapLongInnerEnumHelperPubSubType::MapLongInnerEnumHelperPubSubType() { - setName("MapLongInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerEnumHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerEnumHelper_max_cdr_typesize; -#endif + set_name("MapLongInnerEnumHelper"); + uint32_t type_size = MapLongInnerEnumHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerEnumHelper_max_key_cdr_typesize > 16 ? MapLongInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongInnerEnumHelper_max_key_cdr_typesize > 16 ? MapLongInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongInnerEnumHelperPubSubType::~MapLongInnerEnumHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongInnerEnumHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13407,16 +12503,12 @@ bool MapLongInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13425,18 +12517,14 @@ bool MapLongInnerEnumHelperPubSubType::deserialize( MapLongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13449,52 +12537,62 @@ bool MapLongInnerEnumHelperPubSubType::deserialize( return true; } -std::function MapLongInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongInnerEnumHelperPubSubType::createData() +void* MapLongInnerEnumHelperPubSubType::create_data() { return reinterpret_cast(new MapLongInnerEnumHelper()); } -void MapLongInnerEnumHelperPubSubType::deleteData( +void MapLongInnerEnumHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongInnerEnumHelperPubSubType::getKey( +bool MapLongInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13502,35 +12600,27 @@ bool MapLongInnerEnumHelperPubSubType::getKey( const MapLongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13543,49 +12633,42 @@ void MapLongInnerEnumHelperPubSubType::register_type_object_representation() MapLongInnerBitMaskHelperPubSubType::MapLongInnerBitMaskHelperPubSubType() { - setName("MapLongInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerBitMaskHelper_max_cdr_typesize; -#endif + set_name("MapLongInnerBitMaskHelper"); + uint32_t type_size = MapLongInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapLongInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapLongInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongInnerBitMaskHelperPubSubType::~MapLongInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13600,16 +12683,12 @@ bool MapLongInnerBitMaskHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13618,18 +12697,14 @@ bool MapLongInnerBitMaskHelperPubSubType::deserialize( MapLongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13642,52 +12717,62 @@ bool MapLongInnerBitMaskHelperPubSubType::deserialize( return true; } -std::function MapLongInnerBitMaskHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongInnerBitMaskHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongInnerBitMaskHelperPubSubType::createData() +void* MapLongInnerBitMaskHelperPubSubType::create_data() { return reinterpret_cast(new MapLongInnerBitMaskHelper()); } -void MapLongInnerBitMaskHelperPubSubType::deleteData( +void MapLongInnerBitMaskHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongInnerBitMaskHelperPubSubType::getKey( +bool MapLongInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongInnerBitMaskHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13695,35 +12780,27 @@ bool MapLongInnerBitMaskHelperPubSubType::getKey( const MapLongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongInnerBitMaskHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongInnerBitMaskHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13736,49 +12813,42 @@ void MapLongInnerBitMaskHelperPubSubType::register_type_object_representation() MapLongInnerAliasHelperPubSubType::MapLongInnerAliasHelperPubSubType() { - setName("MapLongInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerAliasHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerAliasHelper_max_cdr_typesize; -#endif + set_name("MapLongInnerAliasHelper"); + uint32_t type_size = MapLongInnerAliasHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerAliasHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongInnerAliasHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongInnerAliasHelperPubSubType::~MapLongInnerAliasHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongInnerAliasHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13793,16 +12863,12 @@ bool MapLongInnerAliasHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13811,18 +12877,14 @@ bool MapLongInnerAliasHelperPubSubType::deserialize( MapLongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13835,336 +12897,138 @@ bool MapLongInnerAliasHelperPubSubType::deserialize( return true; } -std::function MapLongInnerAliasHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapLongInnerAliasHelperPubSubType::createData() -{ - return reinterpret_cast(new MapLongInnerAliasHelper()); -} - -void MapLongInnerAliasHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapLongInnerAliasHelperPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapLongInnerAliasHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapLongInnerAliasHelper_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapLongInnerAliasHelper_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapLongInnerAliasHelperPubSubType::register_type_object_representation() -{ - register_MapLongInnerAliasHelper_type_identifier(type_identifiers_); } -MapLongInnerAliasArrayHelperPubSubType::MapLongInnerAliasArrayHelperPubSubType() +void* MapLongInnerAliasHelperPubSubType::create_data() { - setName("MapLongInnerAliasArrayHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerAliasArrayHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerAliasArrayHelper_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasArrayHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapLongInnerAliasHelper()); } -MapLongInnerAliasArrayHelperPubSubType::~MapLongInnerAliasArrayHelperPubSubType() +void MapLongInnerAliasHelperPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapLongInnerAliasArrayHelperPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapLongInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapLongInnerAliasArrayHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapLongInnerAliasArrayHelperPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapLongInnerAliasArrayHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapLongInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapLongInnerAliasArrayHelperPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapLongInnerAliasArrayHelperPubSubType::createData() -{ - return reinterpret_cast(new MapLongInnerAliasArrayHelper()); -} - -void MapLongInnerAliasArrayHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapLongInnerAliasArrayHelperPubSubType::getKey( +bool MapLongInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapLongInnerAliasArrayHelper* p_type = static_cast(data); + const MapLongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapLongInnerAliasArrayHelper_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapLongInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapLongInnerAliasArrayHelper_max_key_cdr_typesize > 16) + if (force_md5 || MapLongInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapLongInnerAliasArrayHelperPubSubType::register_type_object_representation() +void MapLongInnerAliasHelperPubSubType::register_type_object_representation() { - register_MapLongInnerAliasArrayHelper_type_identifier(type_identifiers_); + register_MapLongInnerAliasHelper_type_identifier(type_identifiers_); } -MapLongInnerAliasSequenceHelperPubSubType::MapLongInnerAliasSequenceHelperPubSubType() +MapLongInnerAliasArrayHelperPubSubType::MapLongInnerAliasArrayHelperPubSubType() { - setName("MapLongInnerAliasSequenceHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerAliasSequenceHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerAliasSequenceHelper_max_cdr_typesize; -#endif + set_name("MapLongInnerAliasArrayHelper"); + uint32_t type_size = MapLongInnerAliasArrayHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasSequenceHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasArrayHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapLongInnerAliasSequenceHelperPubSubType::~MapLongInnerAliasSequenceHelperPubSubType() +MapLongInnerAliasArrayHelperPubSubType::~MapLongInnerAliasArrayHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapLongInnerAliasSequenceHelperPubSubType::serialize( +bool MapLongInnerAliasArrayHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapLongInnerAliasSequenceHelper* p_type = static_cast(data); + const MapLongInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14179,16 +13043,192 @@ bool MapLongInnerAliasSequenceHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapLongInnerAliasArrayHelperPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapLongInnerAliasArrayHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapLongInnerAliasArrayHelperPubSubType::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* MapLongInnerAliasArrayHelperPubSubType::create_data() +{ + return reinterpret_cast(new MapLongInnerAliasArrayHelper()); +} + +void MapLongInnerAliasArrayHelperPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapLongInnerAliasArrayHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongInnerAliasArrayHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongInnerAliasArrayHelperPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapLongInnerAliasArrayHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapLongInnerAliasArrayHelper_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapLongInnerAliasArrayHelper_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 MapLongInnerAliasArrayHelperPubSubType::register_type_object_representation() +{ + register_MapLongInnerAliasArrayHelper_type_identifier(type_identifiers_); +} + +MapLongInnerAliasSequenceHelperPubSubType::MapLongInnerAliasSequenceHelperPubSubType() +{ + set_name("MapLongInnerAliasSequenceHelper"); + uint32_t type_size = MapLongInnerAliasSequenceHelper_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 = MapLongInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasSequenceHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapLongInnerAliasSequenceHelperPubSubType::~MapLongInnerAliasSequenceHelperPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapLongInnerAliasSequenceHelperPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapLongInnerAliasSequenceHelper* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongInnerAliasSequenceHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14197,18 +13237,14 @@ bool MapLongInnerAliasSequenceHelperPubSubType::deserialize( MapLongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14221,52 +13257,62 @@ bool MapLongInnerAliasSequenceHelperPubSubType::deserialize( return true; } -std::function MapLongInnerAliasSequenceHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongInnerAliasSequenceHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongInnerAliasSequenceHelperPubSubType::createData() +void* MapLongInnerAliasSequenceHelperPubSubType::create_data() { return reinterpret_cast(new MapLongInnerAliasSequenceHelper()); } -void MapLongInnerAliasSequenceHelperPubSubType::deleteData( +void MapLongInnerAliasSequenceHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongInnerAliasSequenceHelperPubSubType::getKey( +bool MapLongInnerAliasSequenceHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongInnerAliasSequenceHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongInnerAliasSequenceHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14274,35 +13320,27 @@ bool MapLongInnerAliasSequenceHelperPubSubType::getKey( const MapLongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongInnerAliasSequenceHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongInnerAliasSequenceHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14315,49 +13353,42 @@ void MapLongInnerAliasSequenceHelperPubSubType::register_type_object_representat MapLongInnerAliasMapHelperPubSubType::MapLongInnerAliasMapHelperPubSubType() { - setName("MapLongInnerAliasMapHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerAliasMapHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerAliasMapHelper_max_cdr_typesize; -#endif + set_name("MapLongInnerAliasMapHelper"); + uint32_t type_size = MapLongInnerAliasMapHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasMapHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapLongInnerAliasMapHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongInnerAliasMapHelperPubSubType::~MapLongInnerAliasMapHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongInnerAliasMapHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14372,16 +13403,12 @@ bool MapLongInnerAliasMapHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongInnerAliasMapHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14390,18 +13417,14 @@ bool MapLongInnerAliasMapHelperPubSubType::deserialize( MapLongInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14414,52 +13437,62 @@ bool MapLongInnerAliasMapHelperPubSubType::deserialize( return true; } -std::function MapLongInnerAliasMapHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongInnerAliasMapHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongInnerAliasMapHelperPubSubType::createData() +void* MapLongInnerAliasMapHelperPubSubType::create_data() { return reinterpret_cast(new MapLongInnerAliasMapHelper()); } -void MapLongInnerAliasMapHelperPubSubType::deleteData( +void MapLongInnerAliasMapHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongInnerAliasMapHelperPubSubType::getKey( +bool MapLongInnerAliasMapHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongInnerAliasMapHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongInnerAliasMapHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14467,35 +13500,27 @@ bool MapLongInnerAliasMapHelperPubSubType::getKey( const MapLongInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongInnerAliasMapHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongInnerAliasMapHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14508,49 +13533,42 @@ void MapLongInnerAliasMapHelperPubSubType::register_type_object_representation() MapLongInnerUnionHelperPubSubType::MapLongInnerUnionHelperPubSubType() { - setName("MapLongInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerUnionHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerUnionHelper_max_cdr_typesize; -#endif + set_name("MapLongInnerUnionHelper"); + uint32_t type_size = MapLongInnerUnionHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerUnionHelper_max_key_cdr_typesize > 16 ? MapLongInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongInnerUnionHelper_max_key_cdr_typesize > 16 ? MapLongInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongInnerUnionHelperPubSubType::~MapLongInnerUnionHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongInnerUnionHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14565,16 +13583,12 @@ bool MapLongInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14583,18 +13597,14 @@ bool MapLongInnerUnionHelperPubSubType::deserialize( MapLongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14607,52 +13617,62 @@ bool MapLongInnerUnionHelperPubSubType::deserialize( return true; } -std::function MapLongInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongInnerUnionHelperPubSubType::createData() +void* MapLongInnerUnionHelperPubSubType::create_data() { return reinterpret_cast(new MapLongInnerUnionHelper()); } -void MapLongInnerUnionHelperPubSubType::deleteData( +void MapLongInnerUnionHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongInnerUnionHelperPubSubType::getKey( +bool MapLongInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14660,35 +13680,27 @@ bool MapLongInnerUnionHelperPubSubType::getKey( const MapLongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14701,49 +13713,42 @@ void MapLongInnerUnionHelperPubSubType::register_type_object_representation() MapLongInnerStructureHelperPubSubType::MapLongInnerStructureHelperPubSubType() { - setName("MapLongInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerStructureHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerStructureHelper_max_cdr_typesize; -#endif + set_name("MapLongInnerStructureHelper"); + uint32_t type_size = MapLongInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerStructureHelper_max_key_cdr_typesize > 16 ? MapLongInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongInnerStructureHelper_max_key_cdr_typesize > 16 ? MapLongInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongInnerStructureHelperPubSubType::~MapLongInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14758,16 +13763,12 @@ bool MapLongInnerStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14776,18 +13777,14 @@ bool MapLongInnerStructureHelperPubSubType::deserialize( MapLongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14800,52 +13797,62 @@ bool MapLongInnerStructureHelperPubSubType::deserialize( return true; } -std::function MapLongInnerStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongInnerStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongInnerStructureHelperPubSubType::createData() +void* MapLongInnerStructureHelperPubSubType::create_data() { return reinterpret_cast(new MapLongInnerStructureHelper()); } -void MapLongInnerStructureHelperPubSubType::deleteData( +void MapLongInnerStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongInnerStructureHelperPubSubType::getKey( +bool MapLongInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongInnerStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14853,35 +13860,27 @@ bool MapLongInnerStructureHelperPubSubType::getKey( const MapLongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongInnerStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongInnerStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14894,49 +13893,42 @@ void MapLongInnerStructureHelperPubSubType::register_type_object_representation( MapLongInnerBitsetHelperPubSubType::MapLongInnerBitsetHelperPubSubType() { - setName("MapLongInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - MapLongInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("MapLongInnerBitsetHelper"); + uint32_t type_size = MapLongInnerBitsetHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapLongInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapLongInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongInnerBitsetHelperPubSubType::~MapLongInnerBitsetHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongInnerBitsetHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14951,16 +13943,12 @@ bool MapLongInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14969,18 +13957,14 @@ bool MapLongInnerBitsetHelperPubSubType::deserialize( MapLongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14993,52 +13977,62 @@ bool MapLongInnerBitsetHelperPubSubType::deserialize( return true; } -std::function MapLongInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongInnerBitsetHelperPubSubType::createData() +void* MapLongInnerBitsetHelperPubSubType::create_data() { return reinterpret_cast(new MapLongInnerBitsetHelper()); } -void MapLongInnerBitsetHelperPubSubType::deleteData( +void MapLongInnerBitsetHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongInnerBitsetHelperPubSubType::getKey( +bool MapLongInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15046,35 +14040,27 @@ bool MapLongInnerBitsetHelperPubSubType::getKey( const MapLongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15087,49 +14073,42 @@ void MapLongInnerBitsetHelperPubSubType::register_type_object_representation() MapULongShortPubSubType::MapULongShortPubSubType() { - setName("MapULongShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongShort::getMaxCdrSerializedSize()); -#else - MapULongShort_max_cdr_typesize; -#endif + set_name("MapULongShort"); + uint32_t type_size = MapULongShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongShort_max_key_cdr_typesize > 16 ? MapULongShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongShort_max_key_cdr_typesize > 16 ? MapULongShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongShortPubSubType::~MapULongShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15144,16 +14123,12 @@ bool MapULongShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15162,18 +14137,14 @@ bool MapULongShortPubSubType::deserialize( MapULongShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15186,52 +14157,62 @@ bool MapULongShortPubSubType::deserialize( return true; } -std::function MapULongShortPubSubType::getSerializedSizeProvider( +uint32_t MapULongShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongShortPubSubType::createData() +void* MapULongShortPubSubType::create_data() { return reinterpret_cast(new MapULongShort()); } -void MapULongShortPubSubType::deleteData( +void MapULongShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongShortPubSubType::getKey( +bool MapULongShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15239,35 +14220,27 @@ bool MapULongShortPubSubType::getKey( const MapULongShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15280,49 +14253,42 @@ void MapULongShortPubSubType::register_type_object_representation() MapULongUShortPubSubType::MapULongUShortPubSubType() { - setName("MapULongUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongUShort::getMaxCdrSerializedSize()); -#else - MapULongUShort_max_cdr_typesize; -#endif + set_name("MapULongUShort"); + uint32_t type_size = MapULongUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongUShort_max_key_cdr_typesize > 16 ? MapULongUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongUShort_max_key_cdr_typesize > 16 ? MapULongUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongUShortPubSubType::~MapULongUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15337,16 +14303,12 @@ bool MapULongUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15355,18 +14317,14 @@ bool MapULongUShortPubSubType::deserialize( MapULongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15379,52 +14337,62 @@ bool MapULongUShortPubSubType::deserialize( return true; } -std::function MapULongUShortPubSubType::getSerializedSizeProvider( +uint32_t MapULongUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongUShortPubSubType::createData() +void* MapULongUShortPubSubType::create_data() { return reinterpret_cast(new MapULongUShort()); } -void MapULongUShortPubSubType::deleteData( +void MapULongUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongUShortPubSubType::getKey( +bool MapULongUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15432,35 +14400,27 @@ bool MapULongUShortPubSubType::getKey( const MapULongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15473,49 +14433,42 @@ void MapULongUShortPubSubType::register_type_object_representation() MapULongLongPubSubType::MapULongLongPubSubType() { - setName("MapULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLong::getMaxCdrSerializedSize()); -#else - MapULongLong_max_cdr_typesize; -#endif + set_name("MapULongLong"); + uint32_t type_size = MapULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLong_max_key_cdr_typesize > 16 ? MapULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLong_max_key_cdr_typesize > 16 ? MapULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongPubSubType::~MapULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15530,16 +14483,12 @@ bool MapULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15548,18 +14497,14 @@ bool MapULongLongPubSubType::deserialize( MapULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15572,52 +14517,62 @@ bool MapULongLongPubSubType::deserialize( return true; } -std::function MapULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongPubSubType::createData() +void* MapULongLongPubSubType::create_data() { return reinterpret_cast(new MapULongLong()); } -void MapULongLongPubSubType::deleteData( +void MapULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongPubSubType::getKey( +bool MapULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15625,35 +14580,27 @@ bool MapULongLongPubSubType::getKey( const MapULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15666,49 +14613,42 @@ void MapULongLongPubSubType::register_type_object_representation() MapULongULongPubSubType::MapULongULongPubSubType() { - setName("MapULongULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongULong::getMaxCdrSerializedSize()); -#else - MapULongULong_max_cdr_typesize; -#endif + set_name("MapULongULong"); + uint32_t type_size = MapULongULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongULong_max_key_cdr_typesize > 16 ? MapULongULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongULong_max_key_cdr_typesize > 16 ? MapULongULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongULongPubSubType::~MapULongULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15723,16 +14663,12 @@ bool MapULongULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15741,18 +14677,14 @@ bool MapULongULongPubSubType::deserialize( MapULongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15765,52 +14697,62 @@ bool MapULongULongPubSubType::deserialize( return true; } -std::function MapULongULongPubSubType::getSerializedSizeProvider( +uint32_t MapULongULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongULongPubSubType::createData() +void* MapULongULongPubSubType::create_data() { return reinterpret_cast(new MapULongULong()); } -void MapULongULongPubSubType::deleteData( +void MapULongULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongULongPubSubType::getKey( +bool MapULongULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15818,35 +14760,27 @@ bool MapULongULongPubSubType::getKey( const MapULongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15859,49 +14793,42 @@ void MapULongULongPubSubType::register_type_object_representation() MapKeyULongValueLongLongPubSubType::MapKeyULongValueLongLongPubSubType() { - setName("MapKeyULongValueLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapKeyULongValueLongLong::getMaxCdrSerializedSize()); -#else - MapKeyULongValueLongLong_max_cdr_typesize; -#endif + set_name("MapKeyULongValueLongLong"); + uint32_t type_size = MapKeyULongValueLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapKeyULongValueLongLong_max_key_cdr_typesize > 16 ? MapKeyULongValueLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapKeyULongValueLongLong_max_key_cdr_typesize > 16 ? MapKeyULongValueLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapKeyULongValueLongLongPubSubType::~MapKeyULongValueLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapKeyULongValueLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapKeyULongValueLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15916,16 +14843,12 @@ bool MapKeyULongValueLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapKeyULongValueLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15934,18 +14857,14 @@ bool MapKeyULongValueLongLongPubSubType::deserialize( MapKeyULongValueLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15958,52 +14877,62 @@ bool MapKeyULongValueLongLongPubSubType::deserialize( return true; } -std::function MapKeyULongValueLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapKeyULongValueLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapKeyULongValueLongLongPubSubType::createData() +void* MapKeyULongValueLongLongPubSubType::create_data() { return reinterpret_cast(new MapKeyULongValueLongLong()); } -void MapKeyULongValueLongLongPubSubType::deleteData( +void MapKeyULongValueLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapKeyULongValueLongLongPubSubType::getKey( +bool MapKeyULongValueLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapKeyULongValueLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapKeyULongValueLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16011,35 +14940,27 @@ bool MapKeyULongValueLongLongPubSubType::getKey( const MapKeyULongValueLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapKeyULongValueLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapKeyULongValueLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16052,49 +14973,42 @@ void MapKeyULongValueLongLongPubSubType::register_type_object_representation() MapULongULongLongPubSubType::MapULongULongLongPubSubType() { - setName("MapULongULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongULongLong::getMaxCdrSerializedSize()); -#else - MapULongULongLong_max_cdr_typesize; -#endif + set_name("MapULongULongLong"); + uint32_t type_size = MapULongULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongULongLong_max_key_cdr_typesize > 16 ? MapULongULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongULongLong_max_key_cdr_typesize > 16 ? MapULongULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongULongLongPubSubType::~MapULongULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16109,16 +15023,12 @@ bool MapULongULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16127,18 +15037,14 @@ bool MapULongULongLongPubSubType::deserialize( MapULongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16151,52 +15057,62 @@ bool MapULongULongLongPubSubType::deserialize( return true; } -std::function MapULongULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapULongULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongULongLongPubSubType::createData() +void* MapULongULongLongPubSubType::create_data() { return reinterpret_cast(new MapULongULongLong()); } -void MapULongULongLongPubSubType::deleteData( +void MapULongULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongULongLongPubSubType::getKey( +bool MapULongULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16204,35 +15120,27 @@ bool MapULongULongLongPubSubType::getKey( const MapULongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16245,49 +15153,42 @@ void MapULongULongLongPubSubType::register_type_object_representation() MapULongFloatPubSubType::MapULongFloatPubSubType() { - setName("MapULongFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongFloat::getMaxCdrSerializedSize()); -#else - MapULongFloat_max_cdr_typesize; -#endif + set_name("MapULongFloat"); + uint32_t type_size = MapULongFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongFloat_max_key_cdr_typesize > 16 ? MapULongFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongFloat_max_key_cdr_typesize > 16 ? MapULongFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongFloatPubSubType::~MapULongFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16302,16 +15203,12 @@ bool MapULongFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16320,18 +15217,14 @@ bool MapULongFloatPubSubType::deserialize( MapULongFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16344,52 +15237,62 @@ bool MapULongFloatPubSubType::deserialize( return true; } -std::function MapULongFloatPubSubType::getSerializedSizeProvider( +uint32_t MapULongFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongFloatPubSubType::createData() +void* MapULongFloatPubSubType::create_data() { return reinterpret_cast(new MapULongFloat()); } -void MapULongFloatPubSubType::deleteData( +void MapULongFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongFloatPubSubType::getKey( +bool MapULongFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16397,35 +15300,27 @@ bool MapULongFloatPubSubType::getKey( const MapULongFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16438,49 +15333,42 @@ void MapULongFloatPubSubType::register_type_object_representation() MapULongDoublePubSubType::MapULongDoublePubSubType() { - setName("MapULongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongDouble::getMaxCdrSerializedSize()); -#else - MapULongDouble_max_cdr_typesize; -#endif + set_name("MapULongDouble"); + uint32_t type_size = MapULongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongDouble_max_key_cdr_typesize > 16 ? MapULongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongDouble_max_key_cdr_typesize > 16 ? MapULongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongDoublePubSubType::~MapULongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16495,16 +15383,12 @@ bool MapULongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16513,18 +15397,14 @@ bool MapULongDoublePubSubType::deserialize( MapULongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16537,52 +15417,62 @@ bool MapULongDoublePubSubType::deserialize( return true; } -std::function MapULongDoublePubSubType::getSerializedSizeProvider( +uint32_t MapULongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongDoublePubSubType::createData() +void* MapULongDoublePubSubType::create_data() { return reinterpret_cast(new MapULongDouble()); } -void MapULongDoublePubSubType::deleteData( +void MapULongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongDoublePubSubType::getKey( +bool MapULongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16590,35 +15480,27 @@ bool MapULongDoublePubSubType::getKey( const MapULongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16631,49 +15513,42 @@ void MapULongDoublePubSubType::register_type_object_representation() MapKeyULongValueLongDoublePubSubType::MapKeyULongValueLongDoublePubSubType() { - setName("MapKeyULongValueLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapKeyULongValueLongDouble::getMaxCdrSerializedSize()); -#else - MapKeyULongValueLongDouble_max_cdr_typesize; -#endif + set_name("MapKeyULongValueLongDouble"); + uint32_t type_size = MapKeyULongValueLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapKeyULongValueLongDouble_max_key_cdr_typesize > 16 ? MapKeyULongValueLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapKeyULongValueLongDouble_max_key_cdr_typesize > 16 ? MapKeyULongValueLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapKeyULongValueLongDoublePubSubType::~MapKeyULongValueLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapKeyULongValueLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapKeyULongValueLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16688,16 +15563,12 @@ bool MapKeyULongValueLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapKeyULongValueLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16706,18 +15577,14 @@ bool MapKeyULongValueLongDoublePubSubType::deserialize( MapKeyULongValueLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16730,52 +15597,62 @@ bool MapKeyULongValueLongDoublePubSubType::deserialize( return true; } -std::function MapKeyULongValueLongDoublePubSubType::getSerializedSizeProvider( +uint32_t MapKeyULongValueLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapKeyULongValueLongDoublePubSubType::createData() +void* MapKeyULongValueLongDoublePubSubType::create_data() { return reinterpret_cast(new MapKeyULongValueLongDouble()); } -void MapKeyULongValueLongDoublePubSubType::deleteData( +void MapKeyULongValueLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapKeyULongValueLongDoublePubSubType::getKey( +bool MapKeyULongValueLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapKeyULongValueLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapKeyULongValueLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -16783,35 +15660,27 @@ bool MapKeyULongValueLongDoublePubSubType::getKey( const MapKeyULongValueLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapKeyULongValueLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapKeyULongValueLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -16824,49 +15693,42 @@ void MapKeyULongValueLongDoublePubSubType::register_type_object_representation() MapULongBooleanPubSubType::MapULongBooleanPubSubType() { - setName("MapULongBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongBoolean::getMaxCdrSerializedSize()); -#else - MapULongBoolean_max_cdr_typesize; -#endif + set_name("MapULongBoolean"); + uint32_t type_size = MapULongBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongBoolean_max_key_cdr_typesize > 16 ? MapULongBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongBoolean_max_key_cdr_typesize > 16 ? MapULongBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongBooleanPubSubType::~MapULongBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -16881,16 +15743,12 @@ bool MapULongBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -16899,18 +15757,14 @@ bool MapULongBooleanPubSubType::deserialize( MapULongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -16923,336 +15777,138 @@ bool MapULongBooleanPubSubType::deserialize( return true; } -std::function MapULongBooleanPubSubType::getSerializedSizeProvider( +uint32_t MapULongBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapULongBooleanPubSubType::createData() -{ - return reinterpret_cast(new MapULongBoolean()); -} - -void MapULongBooleanPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapULongBooleanPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapULongBoolean* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapULongBoolean_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapULongBoolean_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapULongBooleanPubSubType::register_type_object_representation() -{ - register_MapULongBoolean_type_identifier(type_identifiers_); } -MapULongOctetPubSubType::MapULongOctetPubSubType() +void* MapULongBooleanPubSubType::create_data() { - setName("MapULongOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongOctet::getMaxCdrSerializedSize()); -#else - MapULongOctet_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongOctet_max_key_cdr_typesize > 16 ? MapULongOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapULongBoolean()); } -MapULongOctetPubSubType::~MapULongOctetPubSubType() +void MapULongBooleanPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapULongOctetPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapULongBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapULongOctet* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapULongOctetPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapULongOctet* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapULongBoolean data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapULongOctetPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapULongOctetPubSubType::createData() -{ - return reinterpret_cast(new MapULongOctet()); -} - -void MapULongOctetPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapULongOctetPubSubType::getKey( +bool MapULongBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapULongOctet* p_type = static_cast(data); + const MapULongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapULongOctet_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapULongBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapULongOctet_max_key_cdr_typesize > 16) + if (force_md5 || MapULongBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapULongOctetPubSubType::register_type_object_representation() +void MapULongBooleanPubSubType::register_type_object_representation() { - register_MapULongOctet_type_identifier(type_identifiers_); + register_MapULongBoolean_type_identifier(type_identifiers_); } -MapULongCharPubSubType::MapULongCharPubSubType() +MapULongOctetPubSubType::MapULongOctetPubSubType() { - setName("MapULongChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongChar::getMaxCdrSerializedSize()); -#else - MapULongChar_max_cdr_typesize; -#endif + set_name("MapULongOctet"); + uint32_t type_size = MapULongOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongChar_max_key_cdr_typesize > 16 ? MapULongChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongOctet_max_key_cdr_typesize > 16 ? MapULongOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapULongCharPubSubType::~MapULongCharPubSubType() +MapULongOctetPubSubType::~MapULongOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapULongCharPubSubType::serialize( +bool MapULongOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapULongChar* p_type = static_cast(data); + const MapULongOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17267,16 +15923,192 @@ bool MapULongCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapULongOctetPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapULongOctet* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapULongOctetPubSubType::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* MapULongOctetPubSubType::create_data() +{ + return reinterpret_cast(new MapULongOctet()); +} + +void MapULongOctetPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapULongOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongOctetPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapULongOctet* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapULongOctet_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapULongOctet_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 MapULongOctetPubSubType::register_type_object_representation() +{ + register_MapULongOctet_type_identifier(type_identifiers_); +} + +MapULongCharPubSubType::MapULongCharPubSubType() +{ + set_name("MapULongChar"); + uint32_t type_size = MapULongChar_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 = MapULongChar_max_key_cdr_typesize > 16 ? MapULongChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapULongCharPubSubType::~MapULongCharPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapULongCharPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapULongChar* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17285,18 +16117,14 @@ bool MapULongCharPubSubType::deserialize( MapULongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17309,52 +16137,62 @@ bool MapULongCharPubSubType::deserialize( return true; } -std::function MapULongCharPubSubType::getSerializedSizeProvider( +uint32_t MapULongCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongCharPubSubType::createData() +void* MapULongCharPubSubType::create_data() { return reinterpret_cast(new MapULongChar()); } -void MapULongCharPubSubType::deleteData( +void MapULongCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongCharPubSubType::getKey( +bool MapULongCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17362,35 +16200,27 @@ bool MapULongCharPubSubType::getKey( const MapULongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17403,49 +16233,42 @@ void MapULongCharPubSubType::register_type_object_representation() MapULongWCharPubSubType::MapULongWCharPubSubType() { - setName("MapULongWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongWChar::getMaxCdrSerializedSize()); -#else - MapULongWChar_max_cdr_typesize; -#endif + set_name("MapULongWChar"); + uint32_t type_size = MapULongWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongWChar_max_key_cdr_typesize > 16 ? MapULongWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongWChar_max_key_cdr_typesize > 16 ? MapULongWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongWCharPubSubType::~MapULongWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17460,16 +16283,12 @@ bool MapULongWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17478,18 +16297,14 @@ bool MapULongWCharPubSubType::deserialize( MapULongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17502,52 +16317,62 @@ bool MapULongWCharPubSubType::deserialize( return true; } -std::function MapULongWCharPubSubType::getSerializedSizeProvider( +uint32_t MapULongWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongWCharPubSubType::createData() +void* MapULongWCharPubSubType::create_data() { return reinterpret_cast(new MapULongWChar()); } -void MapULongWCharPubSubType::deleteData( +void MapULongWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongWCharPubSubType::getKey( +bool MapULongWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17555,35 +16380,27 @@ bool MapULongWCharPubSubType::getKey( const MapULongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17596,49 +16413,42 @@ void MapULongWCharPubSubType::register_type_object_representation() MapULongStringPubSubType::MapULongStringPubSubType() { - setName("MapULongString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongString::getMaxCdrSerializedSize()); -#else - MapULongString_max_cdr_typesize; -#endif + set_name("MapULongString"); + uint32_t type_size = MapULongString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongString_max_key_cdr_typesize > 16 ? MapULongString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongString_max_key_cdr_typesize > 16 ? MapULongString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongStringPubSubType::~MapULongStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17653,16 +16463,12 @@ bool MapULongStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17671,18 +16477,14 @@ bool MapULongStringPubSubType::deserialize( MapULongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17695,52 +16497,62 @@ bool MapULongStringPubSubType::deserialize( return true; } -std::function MapULongStringPubSubType::getSerializedSizeProvider( +uint32_t MapULongStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongStringPubSubType::createData() +void* MapULongStringPubSubType::create_data() { return reinterpret_cast(new MapULongString()); } -void MapULongStringPubSubType::deleteData( +void MapULongStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongStringPubSubType::getKey( +bool MapULongStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17748,35 +16560,27 @@ bool MapULongStringPubSubType::getKey( const MapULongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17789,49 +16593,42 @@ void MapULongStringPubSubType::register_type_object_representation() MapULongWStringPubSubType::MapULongWStringPubSubType() { - setName("MapULongWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongWString::getMaxCdrSerializedSize()); -#else - MapULongWString_max_cdr_typesize; -#endif + set_name("MapULongWString"); + uint32_t type_size = MapULongWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongWString_max_key_cdr_typesize > 16 ? MapULongWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongWString_max_key_cdr_typesize > 16 ? MapULongWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongWStringPubSubType::~MapULongWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -17846,16 +16643,12 @@ bool MapULongWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -17864,18 +16657,14 @@ bool MapULongWStringPubSubType::deserialize( MapULongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -17888,52 +16677,62 @@ bool MapULongWStringPubSubType::deserialize( return true; } -std::function MapULongWStringPubSubType::getSerializedSizeProvider( +uint32_t MapULongWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongWStringPubSubType::createData() +void* MapULongWStringPubSubType::create_data() { return reinterpret_cast(new MapULongWString()); } -void MapULongWStringPubSubType::deleteData( +void MapULongWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongWStringPubSubType::getKey( +bool MapULongWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -17941,35 +16740,27 @@ bool MapULongWStringPubSubType::getKey( const MapULongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -17982,49 +16773,42 @@ void MapULongWStringPubSubType::register_type_object_representation() MapULongInnerAliasBoundedStringHelperPubSubType::MapULongInnerAliasBoundedStringHelperPubSubType() { - setName("MapULongInnerAliasBoundedStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerAliasBoundedStringHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerAliasBoundedStringHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerAliasBoundedStringHelper"); + uint32_t type_size = MapULongInnerAliasBoundedStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerAliasBoundedStringHelperPubSubType::~MapULongInnerAliasBoundedStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerAliasBoundedStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18039,16 +16823,12 @@ bool MapULongInnerAliasBoundedStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerAliasBoundedStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18057,18 +16837,14 @@ bool MapULongInnerAliasBoundedStringHelperPubSubType::deserialize( MapULongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18081,52 +16857,62 @@ bool MapULongInnerAliasBoundedStringHelperPubSubType::deserialize( return true; } -std::function MapULongInnerAliasBoundedStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerAliasBoundedStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongInnerAliasBoundedStringHelperPubSubType::createData() +void* MapULongInnerAliasBoundedStringHelperPubSubType::create_data() { return reinterpret_cast(new MapULongInnerAliasBoundedStringHelper()); } -void MapULongInnerAliasBoundedStringHelperPubSubType::deleteData( +void MapULongInnerAliasBoundedStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongInnerAliasBoundedStringHelperPubSubType::getKey( +bool MapULongInnerAliasBoundedStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongInnerAliasBoundedStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongInnerAliasBoundedStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18134,35 +16920,27 @@ bool MapULongInnerAliasBoundedStringHelperPubSubType::getKey( const MapULongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongInnerAliasBoundedStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18175,49 +16953,42 @@ void MapULongInnerAliasBoundedStringHelperPubSubType::register_type_object_repre MapULongInnerAliasBoundedWStringHelperPubSubType::MapULongInnerAliasBoundedWStringHelperPubSubType() { - setName("MapULongInnerAliasBoundedWStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerAliasBoundedWStringHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerAliasBoundedWStringHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerAliasBoundedWStringHelper"); + uint32_t type_size = MapULongInnerAliasBoundedWStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerAliasBoundedWStringHelperPubSubType::~MapULongInnerAliasBoundedWStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerAliasBoundedWStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18232,16 +17003,12 @@ bool MapULongInnerAliasBoundedWStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerAliasBoundedWStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18250,18 +17017,14 @@ bool MapULongInnerAliasBoundedWStringHelperPubSubType::deserialize( MapULongInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18274,52 +17037,62 @@ bool MapULongInnerAliasBoundedWStringHelperPubSubType::deserialize( return true; } -std::function MapULongInnerAliasBoundedWStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerAliasBoundedWStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongInnerAliasBoundedWStringHelperPubSubType::createData() +void* MapULongInnerAliasBoundedWStringHelperPubSubType::create_data() { return reinterpret_cast(new MapULongInnerAliasBoundedWStringHelper()); } -void MapULongInnerAliasBoundedWStringHelperPubSubType::deleteData( +void MapULongInnerAliasBoundedWStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongInnerAliasBoundedWStringHelperPubSubType::getKey( +bool MapULongInnerAliasBoundedWStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongInnerAliasBoundedWStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongInnerAliasBoundedWStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18327,35 +17100,27 @@ bool MapULongInnerAliasBoundedWStringHelperPubSubType::getKey( const MapULongInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongInnerAliasBoundedWStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18368,49 +17133,42 @@ void MapULongInnerAliasBoundedWStringHelperPubSubType::register_type_object_repr MapULongInnerEnumHelperPubSubType::MapULongInnerEnumHelperPubSubType() { - setName("MapULongInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerEnumHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerEnumHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerEnumHelper"); + uint32_t type_size = MapULongInnerEnumHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerEnumHelper_max_key_cdr_typesize > 16 ? MapULongInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerEnumHelper_max_key_cdr_typesize > 16 ? MapULongInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerEnumHelperPubSubType::~MapULongInnerEnumHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerEnumHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18425,16 +17183,12 @@ bool MapULongInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18443,18 +17197,14 @@ bool MapULongInnerEnumHelperPubSubType::deserialize( MapULongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18467,52 +17217,62 @@ bool MapULongInnerEnumHelperPubSubType::deserialize( return true; } -std::function MapULongInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongInnerEnumHelperPubSubType::createData() +void* MapULongInnerEnumHelperPubSubType::create_data() { return reinterpret_cast(new MapULongInnerEnumHelper()); } -void MapULongInnerEnumHelperPubSubType::deleteData( +void MapULongInnerEnumHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongInnerEnumHelperPubSubType::getKey( +bool MapULongInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18520,35 +17280,27 @@ bool MapULongInnerEnumHelperPubSubType::getKey( const MapULongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18561,49 +17313,42 @@ void MapULongInnerEnumHelperPubSubType::register_type_object_representation() MapULongInnerBitMaskHelperPubSubType::MapULongInnerBitMaskHelperPubSubType() { - setName("MapULongInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerBitMaskHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerBitMaskHelper"); + uint32_t type_size = MapULongInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapULongInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapULongInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerBitMaskHelperPubSubType::~MapULongInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18618,16 +17363,12 @@ bool MapULongInnerBitMaskHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18636,18 +17377,14 @@ bool MapULongInnerBitMaskHelperPubSubType::deserialize( MapULongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18660,52 +17397,62 @@ bool MapULongInnerBitMaskHelperPubSubType::deserialize( return true; } -std::function MapULongInnerBitMaskHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerBitMaskHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongInnerBitMaskHelperPubSubType::createData() +void* MapULongInnerBitMaskHelperPubSubType::create_data() { return reinterpret_cast(new MapULongInnerBitMaskHelper()); } -void MapULongInnerBitMaskHelperPubSubType::deleteData( +void MapULongInnerBitMaskHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongInnerBitMaskHelperPubSubType::getKey( +bool MapULongInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongInnerBitMaskHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18713,35 +17460,27 @@ bool MapULongInnerBitMaskHelperPubSubType::getKey( const MapULongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongInnerBitMaskHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongInnerBitMaskHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18754,49 +17493,42 @@ void MapULongInnerBitMaskHelperPubSubType::register_type_object_representation() MapULongInnerAliasHelperPubSubType::MapULongInnerAliasHelperPubSubType() { - setName("MapULongInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerAliasHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerAliasHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerAliasHelper"); + uint32_t type_size = MapULongInnerAliasHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerAliasHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerAliasHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerAliasHelperPubSubType::~MapULongInnerAliasHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerAliasHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -18811,16 +17543,12 @@ bool MapULongInnerAliasHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -18829,18 +17557,14 @@ bool MapULongInnerAliasHelperPubSubType::deserialize( MapULongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -18853,52 +17577,62 @@ bool MapULongInnerAliasHelperPubSubType::deserialize( return true; } -std::function MapULongInnerAliasHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongInnerAliasHelperPubSubType::createData() +void* MapULongInnerAliasHelperPubSubType::create_data() { return reinterpret_cast(new MapULongInnerAliasHelper()); } -void MapULongInnerAliasHelperPubSubType::deleteData( +void MapULongInnerAliasHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongInnerAliasHelperPubSubType::getKey( +bool MapULongInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -18906,35 +17640,27 @@ bool MapULongInnerAliasHelperPubSubType::getKey( const MapULongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -18947,49 +17673,42 @@ void MapULongInnerAliasHelperPubSubType::register_type_object_representation() MapULongInnerAliasArrayHelperPubSubType::MapULongInnerAliasArrayHelperPubSubType() { - setName("MapULongInnerAliasArrayHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerAliasArrayHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerAliasArrayHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerAliasArrayHelper"); + uint32_t type_size = MapULongInnerAliasArrayHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasArrayHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasArrayHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerAliasArrayHelperPubSubType::~MapULongInnerAliasArrayHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerAliasArrayHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19004,16 +17723,12 @@ bool MapULongInnerAliasArrayHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerAliasArrayHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19022,18 +17737,14 @@ bool MapULongInnerAliasArrayHelperPubSubType::deserialize( MapULongInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -19046,52 +17757,62 @@ bool MapULongInnerAliasArrayHelperPubSubType::deserialize( return true; } -std::function MapULongInnerAliasArrayHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerAliasArrayHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongInnerAliasArrayHelperPubSubType::createData() +void* MapULongInnerAliasArrayHelperPubSubType::create_data() { return reinterpret_cast(new MapULongInnerAliasArrayHelper()); } -void MapULongInnerAliasArrayHelperPubSubType::deleteData( +void MapULongInnerAliasArrayHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongInnerAliasArrayHelperPubSubType::getKey( +bool MapULongInnerAliasArrayHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongInnerAliasArrayHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongInnerAliasArrayHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -19099,35 +17820,27 @@ bool MapULongInnerAliasArrayHelperPubSubType::getKey( const MapULongInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongInnerAliasArrayHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongInnerAliasArrayHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -19140,49 +17853,42 @@ void MapULongInnerAliasArrayHelperPubSubType::register_type_object_representatio MapULongInnerAliasSequenceHelperPubSubType::MapULongInnerAliasSequenceHelperPubSubType() { - setName("MapULongInnerAliasSequenceHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerAliasSequenceHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerAliasSequenceHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerAliasSequenceHelper"); + uint32_t type_size = MapULongInnerAliasSequenceHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasSequenceHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasSequenceHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerAliasSequenceHelperPubSubType::~MapULongInnerAliasSequenceHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerAliasSequenceHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19197,16 +17903,12 @@ bool MapULongInnerAliasSequenceHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerAliasSequenceHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19215,18 +17917,14 @@ bool MapULongInnerAliasSequenceHelperPubSubType::deserialize( MapULongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -19239,52 +17937,62 @@ bool MapULongInnerAliasSequenceHelperPubSubType::deserialize( return true; } -std::function MapULongInnerAliasSequenceHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerAliasSequenceHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongInnerAliasSequenceHelperPubSubType::createData() +void* MapULongInnerAliasSequenceHelperPubSubType::create_data() { return reinterpret_cast(new MapULongInnerAliasSequenceHelper()); } -void MapULongInnerAliasSequenceHelperPubSubType::deleteData( +void MapULongInnerAliasSequenceHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongInnerAliasSequenceHelperPubSubType::getKey( +bool MapULongInnerAliasSequenceHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongInnerAliasSequenceHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongInnerAliasSequenceHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -19292,35 +18000,27 @@ bool MapULongInnerAliasSequenceHelperPubSubType::getKey( const MapULongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongInnerAliasSequenceHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongInnerAliasSequenceHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -19333,49 +18033,42 @@ void MapULongInnerAliasSequenceHelperPubSubType::register_type_object_representa MapULongInnerAliasMapHelperPubSubType::MapULongInnerAliasMapHelperPubSubType() { - setName("MapULongInnerAliasMapHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerAliasMapHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerAliasMapHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerAliasMapHelper"); + uint32_t type_size = MapULongInnerAliasMapHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasMapHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapULongInnerAliasMapHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerAliasMapHelperPubSubType::~MapULongInnerAliasMapHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerAliasMapHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19390,16 +18083,12 @@ bool MapULongInnerAliasMapHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerAliasMapHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19408,18 +18097,14 @@ bool MapULongInnerAliasMapHelperPubSubType::deserialize( MapULongInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -19432,52 +18117,62 @@ bool MapULongInnerAliasMapHelperPubSubType::deserialize( return true; } -std::function MapULongInnerAliasMapHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerAliasMapHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongInnerAliasMapHelperPubSubType::createData() +void* MapULongInnerAliasMapHelperPubSubType::create_data() { return reinterpret_cast(new MapULongInnerAliasMapHelper()); } -void MapULongInnerAliasMapHelperPubSubType::deleteData( +void MapULongInnerAliasMapHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongInnerAliasMapHelperPubSubType::getKey( +bool MapULongInnerAliasMapHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongInnerAliasMapHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongInnerAliasMapHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -19485,35 +18180,27 @@ bool MapULongInnerAliasMapHelperPubSubType::getKey( const MapULongInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongInnerAliasMapHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongInnerAliasMapHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -19526,49 +18213,42 @@ void MapULongInnerAliasMapHelperPubSubType::register_type_object_representation( MapULongInnerUnionHelperPubSubType::MapULongInnerUnionHelperPubSubType() { - setName("MapULongInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerUnionHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerUnionHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerUnionHelper"); + uint32_t type_size = MapULongInnerUnionHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerUnionHelper_max_key_cdr_typesize > 16 ? MapULongInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerUnionHelper_max_key_cdr_typesize > 16 ? MapULongInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerUnionHelperPubSubType::~MapULongInnerUnionHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerUnionHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19583,16 +18263,12 @@ bool MapULongInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19601,18 +18277,14 @@ bool MapULongInnerUnionHelperPubSubType::deserialize( MapULongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -19625,52 +18297,62 @@ bool MapULongInnerUnionHelperPubSubType::deserialize( return true; } -std::function MapULongInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongInnerUnionHelperPubSubType::createData() +void* MapULongInnerUnionHelperPubSubType::create_data() { return reinterpret_cast(new MapULongInnerUnionHelper()); } -void MapULongInnerUnionHelperPubSubType::deleteData( +void MapULongInnerUnionHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongInnerUnionHelperPubSubType::getKey( +bool MapULongInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -19678,35 +18360,27 @@ bool MapULongInnerUnionHelperPubSubType::getKey( const MapULongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -19719,49 +18393,42 @@ void MapULongInnerUnionHelperPubSubType::register_type_object_representation() MapULongInnerStructureHelperPubSubType::MapULongInnerStructureHelperPubSubType() { - setName("MapULongInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerStructureHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerStructureHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerStructureHelper"); + uint32_t type_size = MapULongInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerStructureHelper_max_key_cdr_typesize > 16 ? MapULongInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerStructureHelper_max_key_cdr_typesize > 16 ? MapULongInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerStructureHelperPubSubType::~MapULongInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19776,16 +18443,12 @@ bool MapULongInnerStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19794,18 +18457,14 @@ bool MapULongInnerStructureHelperPubSubType::deserialize( MapULongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -19818,52 +18477,62 @@ bool MapULongInnerStructureHelperPubSubType::deserialize( return true; } -std::function MapULongInnerStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongInnerStructureHelperPubSubType::createData() +void* MapULongInnerStructureHelperPubSubType::create_data() { return reinterpret_cast(new MapULongInnerStructureHelper()); } -void MapULongInnerStructureHelperPubSubType::deleteData( +void MapULongInnerStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongInnerStructureHelperPubSubType::getKey( +bool MapULongInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongInnerStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -19871,35 +18540,27 @@ bool MapULongInnerStructureHelperPubSubType::getKey( const MapULongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongInnerStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongInnerStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -19912,49 +18573,42 @@ void MapULongInnerStructureHelperPubSubType::register_type_object_representation MapULongInnerBitsetHelperPubSubType::MapULongInnerBitsetHelperPubSubType() { - setName("MapULongInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - MapULongInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("MapULongInnerBitsetHelper"); + uint32_t type_size = MapULongInnerBitsetHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapULongInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapULongInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongInnerBitsetHelperPubSubType::~MapULongInnerBitsetHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongInnerBitsetHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -19969,16 +18623,12 @@ bool MapULongInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -19987,18 +18637,14 @@ bool MapULongInnerBitsetHelperPubSubType::deserialize( MapULongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -20011,336 +18657,138 @@ bool MapULongInnerBitsetHelperPubSubType::deserialize( return true; } -std::function MapULongInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapULongInnerBitsetHelperPubSubType::createData() -{ - return reinterpret_cast(new MapULongInnerBitsetHelper()); -} - -void MapULongInnerBitsetHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapULongInnerBitsetHelperPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapULongInnerBitsetHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapULongInnerBitsetHelper_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapULongInnerBitsetHelper_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapULongInnerBitsetHelperPubSubType::register_type_object_representation() -{ - register_MapULongInnerBitsetHelper_type_identifier(type_identifiers_); } -MapLongLongShortPubSubType::MapLongLongShortPubSubType() +void* MapULongInnerBitsetHelperPubSubType::create_data() { - setName("MapLongLongShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongShort::getMaxCdrSerializedSize()); -#else - MapLongLongShort_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongShort_max_key_cdr_typesize > 16 ? MapLongLongShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapULongInnerBitsetHelper()); } -MapLongLongShortPubSubType::~MapLongLongShortPubSubType() +void MapULongInnerBitsetHelperPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapLongLongShortPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapULongInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapLongLongShort* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapLongLongShortPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapLongLongShort* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapULongInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapLongLongShortPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapLongLongShortPubSubType::createData() -{ - return reinterpret_cast(new MapLongLongShort()); -} - -void MapLongLongShortPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapLongLongShortPubSubType::getKey( +bool MapULongInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapLongLongShort* p_type = static_cast(data); + const MapULongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapLongLongShort_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapULongInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapLongLongShort_max_key_cdr_typesize > 16) + if (force_md5 || MapULongInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapLongLongShortPubSubType::register_type_object_representation() +void MapULongInnerBitsetHelperPubSubType::register_type_object_representation() { - register_MapLongLongShort_type_identifier(type_identifiers_); + register_MapULongInnerBitsetHelper_type_identifier(type_identifiers_); } -MapLongLongUShortPubSubType::MapLongLongUShortPubSubType() +MapLongLongShortPubSubType::MapLongLongShortPubSubType() { - setName("MapLongLongUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongUShort::getMaxCdrSerializedSize()); -#else - MapLongLongUShort_max_cdr_typesize; -#endif + set_name("MapLongLongShort"); + uint32_t type_size = MapLongLongShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongUShort_max_key_cdr_typesize > 16 ? MapLongLongUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongShort_max_key_cdr_typesize > 16 ? MapLongLongShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapLongLongUShortPubSubType::~MapLongLongUShortPubSubType() +MapLongLongShortPubSubType::~MapLongLongShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapLongLongUShortPubSubType::serialize( +bool MapLongLongShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapLongLongUShort* p_type = static_cast(data); + const MapLongLongShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -20355,16 +18803,192 @@ bool MapLongLongUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapLongLongShortPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapLongLongShort* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapLongLongShortPubSubType::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* MapLongLongShortPubSubType::create_data() +{ + return reinterpret_cast(new MapLongLongShort()); +} + +void MapLongLongShortPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapLongLongShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongShortPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapLongLongShort* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapLongLongShort_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapLongLongShort_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 MapLongLongShortPubSubType::register_type_object_representation() +{ + register_MapLongLongShort_type_identifier(type_identifiers_); +} + +MapLongLongUShortPubSubType::MapLongLongUShortPubSubType() +{ + set_name("MapLongLongUShort"); + uint32_t type_size = MapLongLongUShort_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 = MapLongLongUShort_max_key_cdr_typesize > 16 ? MapLongLongUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapLongLongUShortPubSubType::~MapLongLongUShortPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapLongLongUShortPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapLongLongUShort* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -20373,18 +18997,14 @@ bool MapLongLongUShortPubSubType::deserialize( MapLongLongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -20397,52 +19017,62 @@ bool MapLongLongUShortPubSubType::deserialize( return true; } -std::function MapLongLongUShortPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongUShortPubSubType::createData() +void* MapLongLongUShortPubSubType::create_data() { return reinterpret_cast(new MapLongLongUShort()); } -void MapLongLongUShortPubSubType::deleteData( +void MapLongLongUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongUShortPubSubType::getKey( +bool MapLongLongUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -20450,35 +19080,27 @@ bool MapLongLongUShortPubSubType::getKey( const MapLongLongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -20491,49 +19113,42 @@ void MapLongLongUShortPubSubType::register_type_object_representation() MapLongLongKeyLongValuePubSubType::MapLongLongKeyLongValuePubSubType() { - setName("MapLongLongKeyLongValue"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongKeyLongValue::getMaxCdrSerializedSize()); -#else - MapLongLongKeyLongValue_max_cdr_typesize; -#endif + set_name("MapLongLongKeyLongValue"); + uint32_t type_size = MapLongLongKeyLongValue_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongKeyLongValue_max_key_cdr_typesize > 16 ? MapLongLongKeyLongValue_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongKeyLongValue_max_key_cdr_typesize > 16 ? MapLongLongKeyLongValue_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongKeyLongValuePubSubType::~MapLongLongKeyLongValuePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongKeyLongValuePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongKeyLongValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -20548,16 +19163,12 @@ bool MapLongLongKeyLongValuePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongKeyLongValuePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -20566,18 +19177,14 @@ bool MapLongLongKeyLongValuePubSubType::deserialize( MapLongLongKeyLongValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -20590,52 +19197,62 @@ bool MapLongLongKeyLongValuePubSubType::deserialize( return true; } -std::function MapLongLongKeyLongValuePubSubType::getSerializedSizeProvider( +uint32_t MapLongLongKeyLongValuePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongKeyLongValuePubSubType::createData() +void* MapLongLongKeyLongValuePubSubType::create_data() { return reinterpret_cast(new MapLongLongKeyLongValue()); } -void MapLongLongKeyLongValuePubSubType::deleteData( +void MapLongLongKeyLongValuePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongKeyLongValuePubSubType::getKey( +bool MapLongLongKeyLongValuePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongKeyLongValue data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongKeyLongValuePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -20643,35 +19260,27 @@ bool MapLongLongKeyLongValuePubSubType::getKey( const MapLongLongKeyLongValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongKeyLongValue_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongKeyLongValue_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -20684,49 +19293,42 @@ void MapLongLongKeyLongValuePubSubType::register_type_object_representation() MapLongLongULongPubSubType::MapLongLongULongPubSubType() { - setName("MapLongLongULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongULong::getMaxCdrSerializedSize()); -#else - MapLongLongULong_max_cdr_typesize; -#endif + set_name("MapLongLongULong"); + uint32_t type_size = MapLongLongULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongULong_max_key_cdr_typesize > 16 ? MapLongLongULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongULong_max_key_cdr_typesize > 16 ? MapLongLongULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongULongPubSubType::~MapLongLongULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -20741,16 +19343,12 @@ bool MapLongLongULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -20759,18 +19357,14 @@ bool MapLongLongULongPubSubType::deserialize( MapLongLongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -20783,52 +19377,62 @@ bool MapLongLongULongPubSubType::deserialize( return true; } -std::function MapLongLongULongPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongULongPubSubType::createData() +void* MapLongLongULongPubSubType::create_data() { return reinterpret_cast(new MapLongLongULong()); } -void MapLongLongULongPubSubType::deleteData( +void MapLongLongULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongULongPubSubType::getKey( +bool MapLongLongULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -20836,35 +19440,27 @@ bool MapLongLongULongPubSubType::getKey( const MapLongLongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -20877,49 +19473,42 @@ void MapLongLongULongPubSubType::register_type_object_representation() MapLongLongLongLongPubSubType::MapLongLongLongLongPubSubType() { - setName("MapLongLongLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongLongLong::getMaxCdrSerializedSize()); -#else - MapLongLongLongLong_max_cdr_typesize; -#endif + set_name("MapLongLongLongLong"); + uint32_t type_size = MapLongLongLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongLongLong_max_key_cdr_typesize > 16 ? MapLongLongLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongLongLong_max_key_cdr_typesize > 16 ? MapLongLongLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongLongLongPubSubType::~MapLongLongLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -20934,16 +19523,12 @@ bool MapLongLongLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -20952,18 +19537,14 @@ bool MapLongLongLongLongPubSubType::deserialize( MapLongLongLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -20976,52 +19557,62 @@ bool MapLongLongLongLongPubSubType::deserialize( return true; } -std::function MapLongLongLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongLongLongPubSubType::createData() +void* MapLongLongLongLongPubSubType::create_data() { return reinterpret_cast(new MapLongLongLongLong()); } -void MapLongLongLongLongPubSubType::deleteData( +void MapLongLongLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongLongLongPubSubType::getKey( +bool MapLongLongLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -21029,35 +19620,27 @@ bool MapLongLongLongLongPubSubType::getKey( const MapLongLongLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -21070,49 +19653,42 @@ void MapLongLongLongLongPubSubType::register_type_object_representation() MapLongLongULongLongPubSubType::MapLongLongULongLongPubSubType() { - setName("MapLongLongULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongULongLong::getMaxCdrSerializedSize()); -#else - MapLongLongULongLong_max_cdr_typesize; -#endif + set_name("MapLongLongULongLong"); + uint32_t type_size = MapLongLongULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongULongLong_max_key_cdr_typesize > 16 ? MapLongLongULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongULongLong_max_key_cdr_typesize > 16 ? MapLongLongULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongULongLongPubSubType::~MapLongLongULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -21127,16 +19703,12 @@ bool MapLongLongULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -21145,18 +19717,14 @@ bool MapLongLongULongLongPubSubType::deserialize( MapLongLongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -21169,52 +19737,62 @@ bool MapLongLongULongLongPubSubType::deserialize( return true; } -std::function MapLongLongULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongULongLongPubSubType::createData() +void* MapLongLongULongLongPubSubType::create_data() { return reinterpret_cast(new MapLongLongULongLong()); } -void MapLongLongULongLongPubSubType::deleteData( +void MapLongLongULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongULongLongPubSubType::getKey( +bool MapLongLongULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -21222,35 +19800,27 @@ bool MapLongLongULongLongPubSubType::getKey( const MapLongLongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -21263,49 +19833,42 @@ void MapLongLongULongLongPubSubType::register_type_object_representation() MapLongLongFloatPubSubType::MapLongLongFloatPubSubType() { - setName("MapLongLongFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongFloat::getMaxCdrSerializedSize()); -#else - MapLongLongFloat_max_cdr_typesize; -#endif + set_name("MapLongLongFloat"); + uint32_t type_size = MapLongLongFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongFloat_max_key_cdr_typesize > 16 ? MapLongLongFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongFloat_max_key_cdr_typesize > 16 ? MapLongLongFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongFloatPubSubType::~MapLongLongFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -21320,16 +19883,12 @@ bool MapLongLongFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -21338,18 +19897,14 @@ bool MapLongLongFloatPubSubType::deserialize( MapLongLongFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -21362,52 +19917,62 @@ bool MapLongLongFloatPubSubType::deserialize( return true; } -std::function MapLongLongFloatPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongFloatPubSubType::createData() +void* MapLongLongFloatPubSubType::create_data() { return reinterpret_cast(new MapLongLongFloat()); } -void MapLongLongFloatPubSubType::deleteData( +void MapLongLongFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongFloatPubSubType::getKey( +bool MapLongLongFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -21415,35 +19980,27 @@ bool MapLongLongFloatPubSubType::getKey( const MapLongLongFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -21456,49 +20013,42 @@ void MapLongLongFloatPubSubType::register_type_object_representation() MapLongLongKeyDoubleValuePubSubType::MapLongLongKeyDoubleValuePubSubType() { - setName("MapLongLongKeyDoubleValue"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongKeyDoubleValue::getMaxCdrSerializedSize()); -#else - MapLongLongKeyDoubleValue_max_cdr_typesize; -#endif + set_name("MapLongLongKeyDoubleValue"); + uint32_t type_size = MapLongLongKeyDoubleValue_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongKeyDoubleValue_max_key_cdr_typesize > 16 ? MapLongLongKeyDoubleValue_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongKeyDoubleValue_max_key_cdr_typesize > 16 ? MapLongLongKeyDoubleValue_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongKeyDoubleValuePubSubType::~MapLongLongKeyDoubleValuePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongKeyDoubleValuePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongKeyDoubleValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -21513,16 +20063,12 @@ bool MapLongLongKeyDoubleValuePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongKeyDoubleValuePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -21531,18 +20077,14 @@ bool MapLongLongKeyDoubleValuePubSubType::deserialize( MapLongLongKeyDoubleValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -21555,52 +20097,62 @@ bool MapLongLongKeyDoubleValuePubSubType::deserialize( return true; } -std::function MapLongLongKeyDoubleValuePubSubType::getSerializedSizeProvider( +uint32_t MapLongLongKeyDoubleValuePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongKeyDoubleValuePubSubType::createData() +void* MapLongLongKeyDoubleValuePubSubType::create_data() { return reinterpret_cast(new MapLongLongKeyDoubleValue()); } -void MapLongLongKeyDoubleValuePubSubType::deleteData( +void MapLongLongKeyDoubleValuePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongKeyDoubleValuePubSubType::getKey( +bool MapLongLongKeyDoubleValuePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongKeyDoubleValue data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongKeyDoubleValuePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -21608,35 +20160,27 @@ bool MapLongLongKeyDoubleValuePubSubType::getKey( const MapLongLongKeyDoubleValue* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongKeyDoubleValue_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongKeyDoubleValue_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -21649,49 +20193,42 @@ void MapLongLongKeyDoubleValuePubSubType::register_type_object_representation() MapLongLongLongDoublePubSubType::MapLongLongLongDoublePubSubType() { - setName("MapLongLongLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongLongDouble::getMaxCdrSerializedSize()); -#else - MapLongLongLongDouble_max_cdr_typesize; -#endif + set_name("MapLongLongLongDouble"); + uint32_t type_size = MapLongLongLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongLongDouble_max_key_cdr_typesize > 16 ? MapLongLongLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongLongDouble_max_key_cdr_typesize > 16 ? MapLongLongLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongLongDoublePubSubType::~MapLongLongLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -21706,16 +20243,12 @@ bool MapLongLongLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -21724,18 +20257,14 @@ bool MapLongLongLongDoublePubSubType::deserialize( MapLongLongLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -21748,52 +20277,62 @@ bool MapLongLongLongDoublePubSubType::deserialize( return true; } -std::function MapLongLongLongDoublePubSubType::getSerializedSizeProvider( +uint32_t MapLongLongLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongLongDoublePubSubType::createData() +void* MapLongLongLongDoublePubSubType::create_data() { return reinterpret_cast(new MapLongLongLongDouble()); } -void MapLongLongLongDoublePubSubType::deleteData( +void MapLongLongLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongLongDoublePubSubType::getKey( +bool MapLongLongLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -21801,35 +20340,27 @@ bool MapLongLongLongDoublePubSubType::getKey( const MapLongLongLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -21842,49 +20373,42 @@ void MapLongLongLongDoublePubSubType::register_type_object_representation() MapLongLongBooleanPubSubType::MapLongLongBooleanPubSubType() { - setName("MapLongLongBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongBoolean::getMaxCdrSerializedSize()); -#else - MapLongLongBoolean_max_cdr_typesize; -#endif + set_name("MapLongLongBoolean"); + uint32_t type_size = MapLongLongBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongBoolean_max_key_cdr_typesize > 16 ? MapLongLongBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongBoolean_max_key_cdr_typesize > 16 ? MapLongLongBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongBooleanPubSubType::~MapLongLongBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -21899,16 +20423,12 @@ bool MapLongLongBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -21917,18 +20437,14 @@ bool MapLongLongBooleanPubSubType::deserialize( MapLongLongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -21941,52 +20457,62 @@ bool MapLongLongBooleanPubSubType::deserialize( return true; } -std::function MapLongLongBooleanPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongBooleanPubSubType::createData() +void* MapLongLongBooleanPubSubType::create_data() { return reinterpret_cast(new MapLongLongBoolean()); } -void MapLongLongBooleanPubSubType::deleteData( +void MapLongLongBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongBooleanPubSubType::getKey( +bool MapLongLongBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -21994,35 +20520,27 @@ bool MapLongLongBooleanPubSubType::getKey( const MapLongLongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -22035,49 +20553,42 @@ void MapLongLongBooleanPubSubType::register_type_object_representation() MapLongLongOctetPubSubType::MapLongLongOctetPubSubType() { - setName("MapLongLongOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongOctet::getMaxCdrSerializedSize()); -#else - MapLongLongOctet_max_cdr_typesize; -#endif + set_name("MapLongLongOctet"); + uint32_t type_size = MapLongLongOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongOctet_max_key_cdr_typesize > 16 ? MapLongLongOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongOctet_max_key_cdr_typesize > 16 ? MapLongLongOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongOctetPubSubType::~MapLongLongOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -22092,16 +20603,12 @@ bool MapLongLongOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -22110,18 +20617,14 @@ bool MapLongLongOctetPubSubType::deserialize( MapLongLongOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -22134,52 +20637,62 @@ bool MapLongLongOctetPubSubType::deserialize( return true; } -std::function MapLongLongOctetPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongOctetPubSubType::createData() +void* MapLongLongOctetPubSubType::create_data() { return reinterpret_cast(new MapLongLongOctet()); } -void MapLongLongOctetPubSubType::deleteData( +void MapLongLongOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongOctetPubSubType::getKey( +bool MapLongLongOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -22187,35 +20700,27 @@ bool MapLongLongOctetPubSubType::getKey( const MapLongLongOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -22228,49 +20733,42 @@ void MapLongLongOctetPubSubType::register_type_object_representation() MapLongLongCharPubSubType::MapLongLongCharPubSubType() { - setName("MapLongLongChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongChar::getMaxCdrSerializedSize()); -#else - MapLongLongChar_max_cdr_typesize; -#endif + set_name("MapLongLongChar"); + uint32_t type_size = MapLongLongChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongChar_max_key_cdr_typesize > 16 ? MapLongLongChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongChar_max_key_cdr_typesize > 16 ? MapLongLongChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongCharPubSubType::~MapLongLongCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -22285,16 +20783,12 @@ bool MapLongLongCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -22303,18 +20797,14 @@ bool MapLongLongCharPubSubType::deserialize( MapLongLongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -22327,52 +20817,62 @@ bool MapLongLongCharPubSubType::deserialize( return true; } -std::function MapLongLongCharPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongCharPubSubType::createData() +void* MapLongLongCharPubSubType::create_data() { return reinterpret_cast(new MapLongLongChar()); } -void MapLongLongCharPubSubType::deleteData( +void MapLongLongCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongCharPubSubType::getKey( +bool MapLongLongCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -22380,35 +20880,27 @@ bool MapLongLongCharPubSubType::getKey( const MapLongLongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -22421,49 +20913,42 @@ void MapLongLongCharPubSubType::register_type_object_representation() MapLongLongWCharPubSubType::MapLongLongWCharPubSubType() { - setName("MapLongLongWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongWChar::getMaxCdrSerializedSize()); -#else - MapLongLongWChar_max_cdr_typesize; -#endif + set_name("MapLongLongWChar"); + uint32_t type_size = MapLongLongWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongWChar_max_key_cdr_typesize > 16 ? MapLongLongWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongWChar_max_key_cdr_typesize > 16 ? MapLongLongWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongWCharPubSubType::~MapLongLongWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -22478,16 +20963,12 @@ bool MapLongLongWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -22496,18 +20977,14 @@ bool MapLongLongWCharPubSubType::deserialize( MapLongLongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -22520,52 +20997,62 @@ bool MapLongLongWCharPubSubType::deserialize( return true; } -std::function MapLongLongWCharPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongWCharPubSubType::createData() +void* MapLongLongWCharPubSubType::create_data() { return reinterpret_cast(new MapLongLongWChar()); } -void MapLongLongWCharPubSubType::deleteData( +void MapLongLongWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongWCharPubSubType::getKey( +bool MapLongLongWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -22573,35 +21060,27 @@ bool MapLongLongWCharPubSubType::getKey( const MapLongLongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -22614,49 +21093,42 @@ void MapLongLongWCharPubSubType::register_type_object_representation() MapLongLongStringPubSubType::MapLongLongStringPubSubType() { - setName("MapLongLongString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongString::getMaxCdrSerializedSize()); -#else - MapLongLongString_max_cdr_typesize; -#endif + set_name("MapLongLongString"); + uint32_t type_size = MapLongLongString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongString_max_key_cdr_typesize > 16 ? MapLongLongString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongString_max_key_cdr_typesize > 16 ? MapLongLongString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongStringPubSubType::~MapLongLongStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -22671,16 +21143,12 @@ bool MapLongLongStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -22689,18 +21157,14 @@ bool MapLongLongStringPubSubType::deserialize( MapLongLongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -22713,52 +21177,62 @@ bool MapLongLongStringPubSubType::deserialize( return true; } -std::function MapLongLongStringPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongStringPubSubType::createData() +void* MapLongLongStringPubSubType::create_data() { return reinterpret_cast(new MapLongLongString()); } -void MapLongLongStringPubSubType::deleteData( +void MapLongLongStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongStringPubSubType::getKey( +bool MapLongLongStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -22766,35 +21240,27 @@ bool MapLongLongStringPubSubType::getKey( const MapLongLongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -22807,49 +21273,42 @@ void MapLongLongStringPubSubType::register_type_object_representation() MapLongLongWStringPubSubType::MapLongLongWStringPubSubType() { - setName("MapLongLongWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongWString::getMaxCdrSerializedSize()); -#else - MapLongLongWString_max_cdr_typesize; -#endif + set_name("MapLongLongWString"); + uint32_t type_size = MapLongLongWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongWString_max_key_cdr_typesize > 16 ? MapLongLongWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongWString_max_key_cdr_typesize > 16 ? MapLongLongWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongWStringPubSubType::~MapLongLongWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -22864,16 +21323,12 @@ bool MapLongLongWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -22882,18 +21337,14 @@ bool MapLongLongWStringPubSubType::deserialize( MapLongLongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -22906,52 +21357,62 @@ bool MapLongLongWStringPubSubType::deserialize( return true; } -std::function MapLongLongWStringPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongWStringPubSubType::createData() +void* MapLongLongWStringPubSubType::create_data() { return reinterpret_cast(new MapLongLongWString()); } -void MapLongLongWStringPubSubType::deleteData( +void MapLongLongWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongWStringPubSubType::getKey( +bool MapLongLongWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -22959,35 +21420,27 @@ bool MapLongLongWStringPubSubType::getKey( const MapLongLongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -23000,49 +21453,42 @@ void MapLongLongWStringPubSubType::register_type_object_representation() MapLongLongInnerAliasBoundedStringHelperPubSubType::MapLongLongInnerAliasBoundedStringHelperPubSubType() { - setName("MapLongLongInnerAliasBoundedStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerAliasBoundedStringHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerAliasBoundedStringHelper_max_cdr_typesize; -#endif + set_name("MapLongLongInnerAliasBoundedStringHelper"); + uint32_t type_size = MapLongLongInnerAliasBoundedStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongInnerAliasBoundedStringHelperPubSubType::~MapLongLongInnerAliasBoundedStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongInnerAliasBoundedStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -23057,16 +21503,12 @@ bool MapLongLongInnerAliasBoundedStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongInnerAliasBoundedStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -23075,18 +21517,14 @@ bool MapLongLongInnerAliasBoundedStringHelperPubSubType::deserialize( MapLongLongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -23099,336 +21537,138 @@ bool MapLongLongInnerAliasBoundedStringHelperPubSubType::deserialize( return true; } -std::function MapLongLongInnerAliasBoundedStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongInnerAliasBoundedStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapLongLongInnerAliasBoundedStringHelperPubSubType::createData() -{ - return reinterpret_cast(new MapLongLongInnerAliasBoundedStringHelper()); -} - -void MapLongLongInnerAliasBoundedStringHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapLongLongInnerAliasBoundedStringHelperPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapLongLongInnerAliasBoundedStringHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapLongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapLongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapLongLongInnerAliasBoundedStringHelperPubSubType::register_type_object_representation() -{ - register_MapLongLongInnerAliasBoundedStringHelper_type_identifier(type_identifiers_); } -MapLongLongInnerAliasBoundedWStringHelperPubSubType::MapLongLongInnerAliasBoundedWStringHelperPubSubType() +void* MapLongLongInnerAliasBoundedStringHelperPubSubType::create_data() { - setName("MapLongLongInnerAliasBoundedWStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerAliasBoundedWStringHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerAliasBoundedWStringHelper_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapLongLongInnerAliasBoundedStringHelper()); } -MapLongLongInnerAliasBoundedWStringHelperPubSubType::~MapLongLongInnerAliasBoundedWStringHelperPubSubType() +void MapLongLongInnerAliasBoundedStringHelperPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapLongLongInnerAliasBoundedWStringHelperPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapLongLongInnerAliasBoundedStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapLongLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapLongLongInnerAliasBoundedWStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapLongLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapLongLongInnerAliasBoundedStringHelper data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapLongLongInnerAliasBoundedWStringHelperPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapLongLongInnerAliasBoundedWStringHelperPubSubType::createData() -{ - return reinterpret_cast(new MapLongLongInnerAliasBoundedWStringHelper()); -} - -void MapLongLongInnerAliasBoundedWStringHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapLongLongInnerAliasBoundedWStringHelperPubSubType::getKey( +bool MapLongLongInnerAliasBoundedStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapLongLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); + const MapLongLongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapLongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapLongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapLongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16) + if (force_md5 || MapLongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapLongLongInnerAliasBoundedWStringHelperPubSubType::register_type_object_representation() +void MapLongLongInnerAliasBoundedStringHelperPubSubType::register_type_object_representation() { - register_MapLongLongInnerAliasBoundedWStringHelper_type_identifier(type_identifiers_); + register_MapLongLongInnerAliasBoundedStringHelper_type_identifier(type_identifiers_); } -MapLongLongInnerEnumHelperPubSubType::MapLongLongInnerEnumHelperPubSubType() +MapLongLongInnerAliasBoundedWStringHelperPubSubType::MapLongLongInnerAliasBoundedWStringHelperPubSubType() { - setName("MapLongLongInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerEnumHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerEnumHelper_max_cdr_typesize; -#endif + set_name("MapLongLongInnerAliasBoundedWStringHelper"); + uint32_t type_size = MapLongLongInnerAliasBoundedWStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerEnumHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapLongLongInnerEnumHelperPubSubType::~MapLongLongInnerEnumHelperPubSubType() +MapLongLongInnerAliasBoundedWStringHelperPubSubType::~MapLongLongInnerAliasBoundedWStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapLongLongInnerEnumHelperPubSubType::serialize( +bool MapLongLongInnerAliasBoundedWStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapLongLongInnerEnumHelper* p_type = static_cast(data); + const MapLongLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -23443,16 +21683,192 @@ bool MapLongLongInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapLongLongInnerAliasBoundedWStringHelperPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapLongLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapLongLongInnerAliasBoundedWStringHelperPubSubType::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* MapLongLongInnerAliasBoundedWStringHelperPubSubType::create_data() +{ + return reinterpret_cast(new MapLongLongInnerAliasBoundedWStringHelper()); +} + +void MapLongLongInnerAliasBoundedWStringHelperPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapLongLongInnerAliasBoundedWStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongInnerAliasBoundedWStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongInnerAliasBoundedWStringHelperPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapLongLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapLongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapLongLongInnerAliasBoundedWStringHelper_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 MapLongLongInnerAliasBoundedWStringHelperPubSubType::register_type_object_representation() +{ + register_MapLongLongInnerAliasBoundedWStringHelper_type_identifier(type_identifiers_); +} + +MapLongLongInnerEnumHelperPubSubType::MapLongLongInnerEnumHelperPubSubType() +{ + set_name("MapLongLongInnerEnumHelper"); + uint32_t type_size = MapLongLongInnerEnumHelper_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 = MapLongLongInnerEnumHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapLongLongInnerEnumHelperPubSubType::~MapLongLongInnerEnumHelperPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapLongLongInnerEnumHelperPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapLongLongInnerEnumHelper* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -23461,18 +21877,14 @@ bool MapLongLongInnerEnumHelperPubSubType::deserialize( MapLongLongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -23485,52 +21897,62 @@ bool MapLongLongInnerEnumHelperPubSubType::deserialize( return true; } -std::function MapLongLongInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongInnerEnumHelperPubSubType::createData() +void* MapLongLongInnerEnumHelperPubSubType::create_data() { return reinterpret_cast(new MapLongLongInnerEnumHelper()); } -void MapLongLongInnerEnumHelperPubSubType::deleteData( +void MapLongLongInnerEnumHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongInnerEnumHelperPubSubType::getKey( +bool MapLongLongInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -23538,35 +21960,27 @@ bool MapLongLongInnerEnumHelperPubSubType::getKey( const MapLongLongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -23579,49 +21993,42 @@ void MapLongLongInnerEnumHelperPubSubType::register_type_object_representation() MapLongLongInnerBitMaskHelperPubSubType::MapLongLongInnerBitMaskHelperPubSubType() { - setName("MapLongLongInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerBitMaskHelper_max_cdr_typesize; -#endif + set_name("MapLongLongInnerBitMaskHelper"); + uint32_t type_size = MapLongLongInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongInnerBitMaskHelperPubSubType::~MapLongLongInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -23636,16 +22043,12 @@ bool MapLongLongInnerBitMaskHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -23654,18 +22057,14 @@ bool MapLongLongInnerBitMaskHelperPubSubType::deserialize( MapLongLongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -23678,52 +22077,62 @@ bool MapLongLongInnerBitMaskHelperPubSubType::deserialize( return true; } -std::function MapLongLongInnerBitMaskHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongInnerBitMaskHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongInnerBitMaskHelperPubSubType::createData() +void* MapLongLongInnerBitMaskHelperPubSubType::create_data() { return reinterpret_cast(new MapLongLongInnerBitMaskHelper()); } -void MapLongLongInnerBitMaskHelperPubSubType::deleteData( +void MapLongLongInnerBitMaskHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongInnerBitMaskHelperPubSubType::getKey( +bool MapLongLongInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongInnerBitMaskHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -23731,35 +22140,27 @@ bool MapLongLongInnerBitMaskHelperPubSubType::getKey( const MapLongLongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongInnerBitMaskHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongInnerBitMaskHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -23772,49 +22173,42 @@ void MapLongLongInnerBitMaskHelperPubSubType::register_type_object_representatio MapLongLongInnerAliasHelperPubSubType::MapLongLongInnerAliasHelperPubSubType() { - setName("MapLongLongInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerAliasHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerAliasHelper_max_cdr_typesize; -#endif + set_name("MapLongLongInnerAliasHelper"); + uint32_t type_size = MapLongLongInnerAliasHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerAliasHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongInnerAliasHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongInnerAliasHelperPubSubType::~MapLongLongInnerAliasHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongInnerAliasHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -23829,16 +22223,12 @@ bool MapLongLongInnerAliasHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -23847,18 +22237,14 @@ bool MapLongLongInnerAliasHelperPubSubType::deserialize( MapLongLongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -23871,52 +22257,62 @@ bool MapLongLongInnerAliasHelperPubSubType::deserialize( return true; } -std::function MapLongLongInnerAliasHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongInnerAliasHelperPubSubType::createData() +void* MapLongLongInnerAliasHelperPubSubType::create_data() { return reinterpret_cast(new MapLongLongInnerAliasHelper()); } -void MapLongLongInnerAliasHelperPubSubType::deleteData( +void MapLongLongInnerAliasHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongInnerAliasHelperPubSubType::getKey( +bool MapLongLongInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -23924,35 +22320,27 @@ bool MapLongLongInnerAliasHelperPubSubType::getKey( const MapLongLongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -23965,49 +22353,42 @@ void MapLongLongInnerAliasHelperPubSubType::register_type_object_representation( MapLongLongInnerAliasArrayHelperPubSubType::MapLongLongInnerAliasArrayHelperPubSubType() { - setName("MapLongLongInnerAliasArrayHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerAliasArrayHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerAliasArrayHelper_max_cdr_typesize; -#endif + set_name("MapLongLongInnerAliasArrayHelper"); + uint32_t type_size = MapLongLongInnerAliasArrayHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasArrayHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasArrayHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongInnerAliasArrayHelperPubSubType::~MapLongLongInnerAliasArrayHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongInnerAliasArrayHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -24022,16 +22403,12 @@ bool MapLongLongInnerAliasArrayHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongInnerAliasArrayHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -24040,18 +22417,14 @@ bool MapLongLongInnerAliasArrayHelperPubSubType::deserialize( MapLongLongInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -24064,52 +22437,62 @@ bool MapLongLongInnerAliasArrayHelperPubSubType::deserialize( return true; } -std::function MapLongLongInnerAliasArrayHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongInnerAliasArrayHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongInnerAliasArrayHelperPubSubType::createData() +void* MapLongLongInnerAliasArrayHelperPubSubType::create_data() { return reinterpret_cast(new MapLongLongInnerAliasArrayHelper()); } -void MapLongLongInnerAliasArrayHelperPubSubType::deleteData( +void MapLongLongInnerAliasArrayHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongInnerAliasArrayHelperPubSubType::getKey( +bool MapLongLongInnerAliasArrayHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongInnerAliasArrayHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongInnerAliasArrayHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -24117,35 +22500,27 @@ bool MapLongLongInnerAliasArrayHelperPubSubType::getKey( const MapLongLongInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongInnerAliasArrayHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongInnerAliasArrayHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -24158,49 +22533,42 @@ void MapLongLongInnerAliasArrayHelperPubSubType::register_type_object_representa MapLongLongInnerAliasSequenceHelperPubSubType::MapLongLongInnerAliasSequenceHelperPubSubType() { - setName("MapLongLongInnerAliasSequenceHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerAliasSequenceHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerAliasSequenceHelper_max_cdr_typesize; -#endif + set_name("MapLongLongInnerAliasSequenceHelper"); + uint32_t type_size = MapLongLongInnerAliasSequenceHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasSequenceHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasSequenceHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongInnerAliasSequenceHelperPubSubType::~MapLongLongInnerAliasSequenceHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongInnerAliasSequenceHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -24215,16 +22583,12 @@ bool MapLongLongInnerAliasSequenceHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongInnerAliasSequenceHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -24233,18 +22597,14 @@ bool MapLongLongInnerAliasSequenceHelperPubSubType::deserialize( MapLongLongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -24257,52 +22617,62 @@ bool MapLongLongInnerAliasSequenceHelperPubSubType::deserialize( return true; } -std::function MapLongLongInnerAliasSequenceHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongInnerAliasSequenceHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongInnerAliasSequenceHelperPubSubType::createData() +void* MapLongLongInnerAliasSequenceHelperPubSubType::create_data() { return reinterpret_cast(new MapLongLongInnerAliasSequenceHelper()); } -void MapLongLongInnerAliasSequenceHelperPubSubType::deleteData( +void MapLongLongInnerAliasSequenceHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongInnerAliasSequenceHelperPubSubType::getKey( +bool MapLongLongInnerAliasSequenceHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongInnerAliasSequenceHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongInnerAliasSequenceHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -24310,35 +22680,27 @@ bool MapLongLongInnerAliasSequenceHelperPubSubType::getKey( const MapLongLongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongInnerAliasSequenceHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongInnerAliasSequenceHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -24351,49 +22713,42 @@ void MapLongLongInnerAliasSequenceHelperPubSubType::register_type_object_represe MapLongLongInnerAliasMapHelperPubSubType::MapLongLongInnerAliasMapHelperPubSubType() { - setName("MapLongLongInnerAliasMapHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerAliasMapHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerAliasMapHelper_max_cdr_typesize; -#endif + set_name("MapLongLongInnerAliasMapHelper"); + uint32_t type_size = MapLongLongInnerAliasMapHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasMapHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerAliasMapHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongInnerAliasMapHelperPubSubType::~MapLongLongInnerAliasMapHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongInnerAliasMapHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -24408,16 +22763,12 @@ bool MapLongLongInnerAliasMapHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongInnerAliasMapHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -24426,18 +22777,14 @@ bool MapLongLongInnerAliasMapHelperPubSubType::deserialize( MapLongLongInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -24450,52 +22797,62 @@ bool MapLongLongInnerAliasMapHelperPubSubType::deserialize( return true; } -std::function MapLongLongInnerAliasMapHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongInnerAliasMapHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongInnerAliasMapHelperPubSubType::createData() +void* MapLongLongInnerAliasMapHelperPubSubType::create_data() { return reinterpret_cast(new MapLongLongInnerAliasMapHelper()); } -void MapLongLongInnerAliasMapHelperPubSubType::deleteData( +void MapLongLongInnerAliasMapHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongInnerAliasMapHelperPubSubType::getKey( +bool MapLongLongInnerAliasMapHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongInnerAliasMapHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongInnerAliasMapHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -24503,35 +22860,27 @@ bool MapLongLongInnerAliasMapHelperPubSubType::getKey( const MapLongLongInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongInnerAliasMapHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongInnerAliasMapHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -24544,49 +22893,42 @@ void MapLongLongInnerAliasMapHelperPubSubType::register_type_object_representati MapLongLongInnerUnionHelperPubSubType::MapLongLongInnerUnionHelperPubSubType() { - setName("MapLongLongInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerUnionHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerUnionHelper_max_cdr_typesize; -#endif + set_name("MapLongLongInnerUnionHelper"); + uint32_t type_size = MapLongLongInnerUnionHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerUnionHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongInnerUnionHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongInnerUnionHelperPubSubType::~MapLongLongInnerUnionHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongInnerUnionHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -24601,16 +22943,12 @@ bool MapLongLongInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -24619,18 +22957,14 @@ bool MapLongLongInnerUnionHelperPubSubType::deserialize( MapLongLongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -24643,52 +22977,62 @@ bool MapLongLongInnerUnionHelperPubSubType::deserialize( return true; } -std::function MapLongLongInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongInnerUnionHelperPubSubType::createData() +void* MapLongLongInnerUnionHelperPubSubType::create_data() { return reinterpret_cast(new MapLongLongInnerUnionHelper()); } -void MapLongLongInnerUnionHelperPubSubType::deleteData( +void MapLongLongInnerUnionHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongInnerUnionHelperPubSubType::getKey( +bool MapLongLongInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -24696,35 +23040,27 @@ bool MapLongLongInnerUnionHelperPubSubType::getKey( const MapLongLongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -24737,49 +23073,42 @@ void MapLongLongInnerUnionHelperPubSubType::register_type_object_representation( MapLongLongInnerStructureHelperPubSubType::MapLongLongInnerStructureHelperPubSubType() { - setName("MapLongLongInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerStructureHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerStructureHelper_max_cdr_typesize; -#endif + set_name("MapLongLongInnerStructureHelper"); + uint32_t type_size = MapLongLongInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerStructureHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongInnerStructureHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongInnerStructureHelperPubSubType::~MapLongLongInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -24794,16 +23123,12 @@ bool MapLongLongInnerStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -24812,18 +23137,14 @@ bool MapLongLongInnerStructureHelperPubSubType::deserialize( MapLongLongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -24836,52 +23157,62 @@ bool MapLongLongInnerStructureHelperPubSubType::deserialize( return true; } -std::function MapLongLongInnerStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongInnerStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongInnerStructureHelperPubSubType::createData() +void* MapLongLongInnerStructureHelperPubSubType::create_data() { return reinterpret_cast(new MapLongLongInnerStructureHelper()); } -void MapLongLongInnerStructureHelperPubSubType::deleteData( +void MapLongLongInnerStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongInnerStructureHelperPubSubType::getKey( +bool MapLongLongInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongInnerStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -24889,35 +23220,27 @@ bool MapLongLongInnerStructureHelperPubSubType::getKey( const MapLongLongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongInnerStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongInnerStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -24930,49 +23253,42 @@ void MapLongLongInnerStructureHelperPubSubType::register_type_object_representat MapLongLongInnerBitsetHelperPubSubType::MapLongLongInnerBitsetHelperPubSubType() { - setName("MapLongLongInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapLongLongInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - MapLongLongInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("MapLongLongInnerBitsetHelper"); + uint32_t type_size = MapLongLongInnerBitsetHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapLongLongInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapLongLongInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapLongLongInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapLongLongInnerBitsetHelperPubSubType::~MapLongLongInnerBitsetHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapLongLongInnerBitsetHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapLongLongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -24987,16 +23303,12 @@ bool MapLongLongInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapLongLongInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -25005,18 +23317,14 @@ bool MapLongLongInnerBitsetHelperPubSubType::deserialize( MapLongLongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -25029,52 +23337,62 @@ bool MapLongLongInnerBitsetHelperPubSubType::deserialize( return true; } -std::function MapLongLongInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t MapLongLongInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapLongLongInnerBitsetHelperPubSubType::createData() +void* MapLongLongInnerBitsetHelperPubSubType::create_data() { return reinterpret_cast(new MapLongLongInnerBitsetHelper()); } -void MapLongLongInnerBitsetHelperPubSubType::deleteData( +void MapLongLongInnerBitsetHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapLongLongInnerBitsetHelperPubSubType::getKey( +bool MapLongLongInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapLongLongInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapLongLongInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -25082,35 +23400,27 @@ bool MapLongLongInnerBitsetHelperPubSubType::getKey( const MapLongLongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapLongLongInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapLongLongInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -25123,49 +23433,42 @@ void MapLongLongInnerBitsetHelperPubSubType::register_type_object_representation MapULongLongShortPubSubType::MapULongLongShortPubSubType() { - setName("MapULongLongShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongShort::getMaxCdrSerializedSize()); -#else - MapULongLongShort_max_cdr_typesize; -#endif + set_name("MapULongLongShort"); + uint32_t type_size = MapULongLongShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongShort_max_key_cdr_typesize > 16 ? MapULongLongShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongShort_max_key_cdr_typesize > 16 ? MapULongLongShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongShortPubSubType::~MapULongLongShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -25180,16 +23483,12 @@ bool MapULongLongShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -25198,18 +23497,14 @@ bool MapULongLongShortPubSubType::deserialize( MapULongLongShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -25222,52 +23517,62 @@ bool MapULongLongShortPubSubType::deserialize( return true; } -std::function MapULongLongShortPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongShortPubSubType::createData() +void* MapULongLongShortPubSubType::create_data() { return reinterpret_cast(new MapULongLongShort()); } -void MapULongLongShortPubSubType::deleteData( +void MapULongLongShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongShortPubSubType::getKey( +bool MapULongLongShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -25275,35 +23580,27 @@ bool MapULongLongShortPubSubType::getKey( const MapULongLongShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -25316,49 +23613,42 @@ void MapULongLongShortPubSubType::register_type_object_representation() MapULongLongUShortPubSubType::MapULongLongUShortPubSubType() { - setName("MapULongLongUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongUShort::getMaxCdrSerializedSize()); -#else - MapULongLongUShort_max_cdr_typesize; -#endif + set_name("MapULongLongUShort"); + uint32_t type_size = MapULongLongUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongUShort_max_key_cdr_typesize > 16 ? MapULongLongUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongUShort_max_key_cdr_typesize > 16 ? MapULongLongUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongUShortPubSubType::~MapULongLongUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -25373,16 +23663,12 @@ bool MapULongLongUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -25391,18 +23677,14 @@ bool MapULongLongUShortPubSubType::deserialize( MapULongLongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -25415,52 +23697,62 @@ bool MapULongLongUShortPubSubType::deserialize( return true; } -std::function MapULongLongUShortPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongUShortPubSubType::createData() +void* MapULongLongUShortPubSubType::create_data() { return reinterpret_cast(new MapULongLongUShort()); } -void MapULongLongUShortPubSubType::deleteData( +void MapULongLongUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongUShortPubSubType::getKey( +bool MapULongLongUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -25468,35 +23760,27 @@ bool MapULongLongUShortPubSubType::getKey( const MapULongLongUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -25509,49 +23793,42 @@ void MapULongLongUShortPubSubType::register_type_object_representation() MapULongLongLongPubSubType::MapULongLongLongPubSubType() { - setName("MapULongLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongLong::getMaxCdrSerializedSize()); -#else - MapULongLongLong_max_cdr_typesize; -#endif + set_name("MapULongLongLong"); + uint32_t type_size = MapULongLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongLong_max_key_cdr_typesize > 16 ? MapULongLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongLong_max_key_cdr_typesize > 16 ? MapULongLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongLongPubSubType::~MapULongLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -25566,16 +23843,12 @@ bool MapULongLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -25584,18 +23857,14 @@ bool MapULongLongLongPubSubType::deserialize( MapULongLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -25608,52 +23877,62 @@ bool MapULongLongLongPubSubType::deserialize( return true; } -std::function MapULongLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongLongPubSubType::createData() +void* MapULongLongLongPubSubType::create_data() { return reinterpret_cast(new MapULongLongLong()); } -void MapULongLongLongPubSubType::deleteData( +void MapULongLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongLongPubSubType::getKey( +bool MapULongLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -25661,35 +23940,27 @@ bool MapULongLongLongPubSubType::getKey( const MapULongLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -25702,49 +23973,42 @@ void MapULongLongLongPubSubType::register_type_object_representation() MapULongLongULongPubSubType::MapULongLongULongPubSubType() { - setName("MapULongLongULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongULong::getMaxCdrSerializedSize()); -#else - MapULongLongULong_max_cdr_typesize; -#endif + set_name("MapULongLongULong"); + uint32_t type_size = MapULongLongULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongULong_max_key_cdr_typesize > 16 ? MapULongLongULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongULong_max_key_cdr_typesize > 16 ? MapULongLongULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongULongPubSubType::~MapULongLongULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -25759,16 +24023,12 @@ bool MapULongLongULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -25777,18 +24037,14 @@ bool MapULongLongULongPubSubType::deserialize( MapULongLongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -25801,52 +24057,62 @@ bool MapULongLongULongPubSubType::deserialize( return true; } -std::function MapULongLongULongPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongULongPubSubType::createData() +void* MapULongLongULongPubSubType::create_data() { return reinterpret_cast(new MapULongLongULong()); } -void MapULongLongULongPubSubType::deleteData( +void MapULongLongULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongULongPubSubType::getKey( +bool MapULongLongULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -25854,35 +24120,27 @@ bool MapULongLongULongPubSubType::getKey( const MapULongLongULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -25895,49 +24153,42 @@ void MapULongLongULongPubSubType::register_type_object_representation() MapULongLongLongLongPubSubType::MapULongLongLongLongPubSubType() { - setName("MapULongLongLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongLongLong::getMaxCdrSerializedSize()); -#else - MapULongLongLongLong_max_cdr_typesize; -#endif + set_name("MapULongLongLongLong"); + uint32_t type_size = MapULongLongLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongLongLong_max_key_cdr_typesize > 16 ? MapULongLongLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongLongLong_max_key_cdr_typesize > 16 ? MapULongLongLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongLongLongPubSubType::~MapULongLongLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -25952,16 +24203,12 @@ bool MapULongLongLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -25970,18 +24217,14 @@ bool MapULongLongLongLongPubSubType::deserialize( MapULongLongLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -25994,52 +24237,62 @@ bool MapULongLongLongLongPubSubType::deserialize( return true; } -std::function MapULongLongLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongLongLongPubSubType::createData() +void* MapULongLongLongLongPubSubType::create_data() { return reinterpret_cast(new MapULongLongLongLong()); } -void MapULongLongLongLongPubSubType::deleteData( +void MapULongLongLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongLongLongPubSubType::getKey( +bool MapULongLongLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -26047,35 +24300,27 @@ bool MapULongLongLongLongPubSubType::getKey( const MapULongLongLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -26088,49 +24333,42 @@ void MapULongLongLongLongPubSubType::register_type_object_representation() MapULongLongULongLongPubSubType::MapULongLongULongLongPubSubType() { - setName("MapULongLongULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongULongLong::getMaxCdrSerializedSize()); -#else - MapULongLongULongLong_max_cdr_typesize; -#endif + set_name("MapULongLongULongLong"); + uint32_t type_size = MapULongLongULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongULongLong_max_key_cdr_typesize > 16 ? MapULongLongULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongULongLong_max_key_cdr_typesize > 16 ? MapULongLongULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongULongLongPubSubType::~MapULongLongULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -26145,16 +24383,12 @@ bool MapULongLongULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -26163,18 +24397,14 @@ bool MapULongLongULongLongPubSubType::deserialize( MapULongLongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -26187,336 +24417,138 @@ bool MapULongLongULongLongPubSubType::deserialize( return true; } -std::function MapULongLongULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapULongLongULongLongPubSubType::createData() -{ - return reinterpret_cast(new MapULongLongULongLong()); -} - -void MapULongLongULongLongPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapULongLongULongLongPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapULongLongULongLong* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapULongLongULongLong_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapULongLongULongLong_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapULongLongULongLongPubSubType::register_type_object_representation() -{ - register_MapULongLongULongLong_type_identifier(type_identifiers_); } -MapULongLongFloatPubSubType::MapULongLongFloatPubSubType() +void* MapULongLongULongLongPubSubType::create_data() { - setName("MapULongLongFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongFloat::getMaxCdrSerializedSize()); -#else - MapULongLongFloat_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongFloat_max_key_cdr_typesize > 16 ? MapULongLongFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapULongLongULongLong()); } -MapULongLongFloatPubSubType::~MapULongLongFloatPubSubType() +void MapULongLongULongLongPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapULongLongFloatPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapULongLongULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapULongLongFloat* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapULongLongFloatPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapULongLongFloat* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapULongLongULongLong data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapULongLongFloatPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapULongLongFloatPubSubType::createData() -{ - return reinterpret_cast(new MapULongLongFloat()); -} - -void MapULongLongFloatPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapULongLongFloatPubSubType::getKey( +bool MapULongLongULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapULongLongFloat* p_type = static_cast(data); + const MapULongLongULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapULongLongFloat_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapULongLongULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapULongLongFloat_max_key_cdr_typesize > 16) + if (force_md5 || MapULongLongULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapULongLongFloatPubSubType::register_type_object_representation() +void MapULongLongULongLongPubSubType::register_type_object_representation() { - register_MapULongLongFloat_type_identifier(type_identifiers_); + register_MapULongLongULongLong_type_identifier(type_identifiers_); } -MapKeyULongLongValueDoublePubSubType::MapKeyULongLongValueDoublePubSubType() +MapULongLongFloatPubSubType::MapULongLongFloatPubSubType() { - setName("MapKeyULongLongValueDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapKeyULongLongValueDouble::getMaxCdrSerializedSize()); -#else - MapKeyULongLongValueDouble_max_cdr_typesize; -#endif + set_name("MapULongLongFloat"); + uint32_t type_size = MapULongLongFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapKeyULongLongValueDouble_max_key_cdr_typesize > 16 ? MapKeyULongLongValueDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongFloat_max_key_cdr_typesize > 16 ? MapULongLongFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapKeyULongLongValueDoublePubSubType::~MapKeyULongLongValueDoublePubSubType() +MapULongLongFloatPubSubType::~MapULongLongFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapKeyULongLongValueDoublePubSubType::serialize( +bool MapULongLongFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapKeyULongLongValueDouble* p_type = static_cast(data); + const MapULongLongFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -26531,16 +24563,192 @@ bool MapKeyULongLongValueDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapULongLongFloatPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapULongLongFloat* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapULongLongFloatPubSubType::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* MapULongLongFloatPubSubType::create_data() +{ + return reinterpret_cast(new MapULongLongFloat()); +} + +void MapULongLongFloatPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapULongLongFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongFloatPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapULongLongFloat* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapULongLongFloat_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapULongLongFloat_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 MapULongLongFloatPubSubType::register_type_object_representation() +{ + register_MapULongLongFloat_type_identifier(type_identifiers_); +} + +MapKeyULongLongValueDoublePubSubType::MapKeyULongLongValueDoublePubSubType() +{ + set_name("MapKeyULongLongValueDouble"); + uint32_t type_size = MapKeyULongLongValueDouble_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 = MapKeyULongLongValueDouble_max_key_cdr_typesize > 16 ? MapKeyULongLongValueDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapKeyULongLongValueDoublePubSubType::~MapKeyULongLongValueDoublePubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapKeyULongLongValueDoublePubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapKeyULongLongValueDouble* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapKeyULongLongValueDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -26549,18 +24757,14 @@ bool MapKeyULongLongValueDoublePubSubType::deserialize( MapKeyULongLongValueDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -26573,52 +24777,62 @@ bool MapKeyULongLongValueDoublePubSubType::deserialize( return true; } -std::function MapKeyULongLongValueDoublePubSubType::getSerializedSizeProvider( +uint32_t MapKeyULongLongValueDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapKeyULongLongValueDoublePubSubType::createData() +void* MapKeyULongLongValueDoublePubSubType::create_data() { return reinterpret_cast(new MapKeyULongLongValueDouble()); } -void MapKeyULongLongValueDoublePubSubType::deleteData( +void MapKeyULongLongValueDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapKeyULongLongValueDoublePubSubType::getKey( +bool MapKeyULongLongValueDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapKeyULongLongValueDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapKeyULongLongValueDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -26626,35 +24840,27 @@ bool MapKeyULongLongValueDoublePubSubType::getKey( const MapKeyULongLongValueDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapKeyULongLongValueDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapKeyULongLongValueDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -26667,49 +24873,42 @@ void MapKeyULongLongValueDoublePubSubType::register_type_object_representation() MapULongLongLongDoublePubSubType::MapULongLongLongDoublePubSubType() { - setName("MapULongLongLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongLongDouble::getMaxCdrSerializedSize()); -#else - MapULongLongLongDouble_max_cdr_typesize; -#endif + set_name("MapULongLongLongDouble"); + uint32_t type_size = MapULongLongLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongLongDouble_max_key_cdr_typesize > 16 ? MapULongLongLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongLongDouble_max_key_cdr_typesize > 16 ? MapULongLongLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongLongDoublePubSubType::~MapULongLongLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -26724,16 +24923,12 @@ bool MapULongLongLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -26742,18 +24937,14 @@ bool MapULongLongLongDoublePubSubType::deserialize( MapULongLongLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -26766,52 +24957,62 @@ bool MapULongLongLongDoublePubSubType::deserialize( return true; } -std::function MapULongLongLongDoublePubSubType::getSerializedSizeProvider( +uint32_t MapULongLongLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongLongDoublePubSubType::createData() +void* MapULongLongLongDoublePubSubType::create_data() { return reinterpret_cast(new MapULongLongLongDouble()); } -void MapULongLongLongDoublePubSubType::deleteData( +void MapULongLongLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongLongDoublePubSubType::getKey( +bool MapULongLongLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -26819,35 +25020,27 @@ bool MapULongLongLongDoublePubSubType::getKey( const MapULongLongLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -26860,49 +25053,42 @@ void MapULongLongLongDoublePubSubType::register_type_object_representation() MapULongLongBooleanPubSubType::MapULongLongBooleanPubSubType() { - setName("MapULongLongBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongBoolean::getMaxCdrSerializedSize()); -#else - MapULongLongBoolean_max_cdr_typesize; -#endif + set_name("MapULongLongBoolean"); + uint32_t type_size = MapULongLongBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongBoolean_max_key_cdr_typesize > 16 ? MapULongLongBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongBoolean_max_key_cdr_typesize > 16 ? MapULongLongBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongBooleanPubSubType::~MapULongLongBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -26917,16 +25103,12 @@ bool MapULongLongBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -26935,18 +25117,14 @@ bool MapULongLongBooleanPubSubType::deserialize( MapULongLongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -26959,52 +25137,62 @@ bool MapULongLongBooleanPubSubType::deserialize( return true; } -std::function MapULongLongBooleanPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongBooleanPubSubType::createData() +void* MapULongLongBooleanPubSubType::create_data() { return reinterpret_cast(new MapULongLongBoolean()); } -void MapULongLongBooleanPubSubType::deleteData( +void MapULongLongBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongBooleanPubSubType::getKey( +bool MapULongLongBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -27012,35 +25200,27 @@ bool MapULongLongBooleanPubSubType::getKey( const MapULongLongBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -27053,49 +25233,42 @@ void MapULongLongBooleanPubSubType::register_type_object_representation() MapULongLongOctetPubSubType::MapULongLongOctetPubSubType() { - setName("MapULongLongOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongOctet::getMaxCdrSerializedSize()); -#else - MapULongLongOctet_max_cdr_typesize; -#endif + set_name("MapULongLongOctet"); + uint32_t type_size = MapULongLongOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongOctet_max_key_cdr_typesize > 16 ? MapULongLongOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongOctet_max_key_cdr_typesize > 16 ? MapULongLongOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongOctetPubSubType::~MapULongLongOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -27110,16 +25283,12 @@ bool MapULongLongOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -27128,18 +25297,14 @@ bool MapULongLongOctetPubSubType::deserialize( MapULongLongOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -27152,52 +25317,62 @@ bool MapULongLongOctetPubSubType::deserialize( return true; } -std::function MapULongLongOctetPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongOctetPubSubType::createData() +void* MapULongLongOctetPubSubType::create_data() { return reinterpret_cast(new MapULongLongOctet()); } -void MapULongLongOctetPubSubType::deleteData( +void MapULongLongOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongOctetPubSubType::getKey( +bool MapULongLongOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -27205,35 +25380,27 @@ bool MapULongLongOctetPubSubType::getKey( const MapULongLongOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -27246,49 +25413,42 @@ void MapULongLongOctetPubSubType::register_type_object_representation() MapULongLongCharPubSubType::MapULongLongCharPubSubType() { - setName("MapULongLongChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongChar::getMaxCdrSerializedSize()); -#else - MapULongLongChar_max_cdr_typesize; -#endif + set_name("MapULongLongChar"); + uint32_t type_size = MapULongLongChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongChar_max_key_cdr_typesize > 16 ? MapULongLongChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongChar_max_key_cdr_typesize > 16 ? MapULongLongChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongCharPubSubType::~MapULongLongCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -27303,16 +25463,12 @@ bool MapULongLongCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -27321,18 +25477,14 @@ bool MapULongLongCharPubSubType::deserialize( MapULongLongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -27345,52 +25497,62 @@ bool MapULongLongCharPubSubType::deserialize( return true; } -std::function MapULongLongCharPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongCharPubSubType::createData() +void* MapULongLongCharPubSubType::create_data() { return reinterpret_cast(new MapULongLongChar()); } -void MapULongLongCharPubSubType::deleteData( +void MapULongLongCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongCharPubSubType::getKey( +bool MapULongLongCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -27398,35 +25560,27 @@ bool MapULongLongCharPubSubType::getKey( const MapULongLongChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -27439,49 +25593,42 @@ void MapULongLongCharPubSubType::register_type_object_representation() MapULongLongWCharPubSubType::MapULongLongWCharPubSubType() { - setName("MapULongLongWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongWChar::getMaxCdrSerializedSize()); -#else - MapULongLongWChar_max_cdr_typesize; -#endif + set_name("MapULongLongWChar"); + uint32_t type_size = MapULongLongWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongWChar_max_key_cdr_typesize > 16 ? MapULongLongWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongWChar_max_key_cdr_typesize > 16 ? MapULongLongWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongWCharPubSubType::~MapULongLongWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -27496,16 +25643,12 @@ bool MapULongLongWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -27514,18 +25657,14 @@ bool MapULongLongWCharPubSubType::deserialize( MapULongLongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -27538,52 +25677,62 @@ bool MapULongLongWCharPubSubType::deserialize( return true; } -std::function MapULongLongWCharPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongWCharPubSubType::createData() +void* MapULongLongWCharPubSubType::create_data() { return reinterpret_cast(new MapULongLongWChar()); } -void MapULongLongWCharPubSubType::deleteData( +void MapULongLongWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongWCharPubSubType::getKey( +bool MapULongLongWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -27591,35 +25740,27 @@ bool MapULongLongWCharPubSubType::getKey( const MapULongLongWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -27632,49 +25773,42 @@ void MapULongLongWCharPubSubType::register_type_object_representation() MapULongLongStringPubSubType::MapULongLongStringPubSubType() { - setName("MapULongLongString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongString::getMaxCdrSerializedSize()); -#else - MapULongLongString_max_cdr_typesize; -#endif + set_name("MapULongLongString"); + uint32_t type_size = MapULongLongString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongString_max_key_cdr_typesize > 16 ? MapULongLongString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongString_max_key_cdr_typesize > 16 ? MapULongLongString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongStringPubSubType::~MapULongLongStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -27689,16 +25823,12 @@ bool MapULongLongStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -27707,18 +25837,14 @@ bool MapULongLongStringPubSubType::deserialize( MapULongLongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -27731,52 +25857,62 @@ bool MapULongLongStringPubSubType::deserialize( return true; } -std::function MapULongLongStringPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongStringPubSubType::createData() +void* MapULongLongStringPubSubType::create_data() { return reinterpret_cast(new MapULongLongString()); } -void MapULongLongStringPubSubType::deleteData( +void MapULongLongStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongStringPubSubType::getKey( +bool MapULongLongStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -27784,35 +25920,27 @@ bool MapULongLongStringPubSubType::getKey( const MapULongLongString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -27825,49 +25953,42 @@ void MapULongLongStringPubSubType::register_type_object_representation() MapULongLongWStringPubSubType::MapULongLongWStringPubSubType() { - setName("MapULongLongWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongWString::getMaxCdrSerializedSize()); -#else - MapULongLongWString_max_cdr_typesize; -#endif + set_name("MapULongLongWString"); + uint32_t type_size = MapULongLongWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongWString_max_key_cdr_typesize > 16 ? MapULongLongWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongWString_max_key_cdr_typesize > 16 ? MapULongLongWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongWStringPubSubType::~MapULongLongWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -27882,16 +26003,12 @@ bool MapULongLongWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -27900,18 +26017,14 @@ bool MapULongLongWStringPubSubType::deserialize( MapULongLongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -27924,52 +26037,62 @@ bool MapULongLongWStringPubSubType::deserialize( return true; } -std::function MapULongLongWStringPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongWStringPubSubType::createData() +void* MapULongLongWStringPubSubType::create_data() { return reinterpret_cast(new MapULongLongWString()); } -void MapULongLongWStringPubSubType::deleteData( +void MapULongLongWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongWStringPubSubType::getKey( +bool MapULongLongWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -27977,35 +26100,27 @@ bool MapULongLongWStringPubSubType::getKey( const MapULongLongWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -28018,49 +26133,42 @@ void MapULongLongWStringPubSubType::register_type_object_representation() MapULongLongInnerAliasBoundedStringHelperPubSubType::MapULongLongInnerAliasBoundedStringHelperPubSubType() { - setName("MapULongLongInnerAliasBoundedStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerAliasBoundedStringHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerAliasBoundedStringHelper_max_cdr_typesize; -#endif + set_name("MapULongLongInnerAliasBoundedStringHelper"); + uint32_t type_size = MapULongLongInnerAliasBoundedStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongInnerAliasBoundedStringHelperPubSubType::~MapULongLongInnerAliasBoundedStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongInnerAliasBoundedStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -28075,16 +26183,12 @@ bool MapULongLongInnerAliasBoundedStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongInnerAliasBoundedStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -28093,18 +26197,14 @@ bool MapULongLongInnerAliasBoundedStringHelperPubSubType::deserialize( MapULongLongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -28117,52 +26217,62 @@ bool MapULongLongInnerAliasBoundedStringHelperPubSubType::deserialize( return true; } -std::function MapULongLongInnerAliasBoundedStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongInnerAliasBoundedStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongInnerAliasBoundedStringHelperPubSubType::createData() +void* MapULongLongInnerAliasBoundedStringHelperPubSubType::create_data() { return reinterpret_cast(new MapULongLongInnerAliasBoundedStringHelper()); } -void MapULongLongInnerAliasBoundedStringHelperPubSubType::deleteData( +void MapULongLongInnerAliasBoundedStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongInnerAliasBoundedStringHelperPubSubType::getKey( +bool MapULongLongInnerAliasBoundedStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongInnerAliasBoundedStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongInnerAliasBoundedStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -28170,35 +26280,27 @@ bool MapULongLongInnerAliasBoundedStringHelperPubSubType::getKey( const MapULongLongInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -28211,49 +26313,42 @@ void MapULongLongInnerAliasBoundedStringHelperPubSubType::register_type_object_r MapULongLongInnerAliasBoundedWStringHelperPubSubType::MapULongLongInnerAliasBoundedWStringHelperPubSubType() { - setName("MapULongLongInnerAliasBoundedWStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerAliasBoundedWStringHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerAliasBoundedWStringHelper_max_cdr_typesize; -#endif + set_name("MapULongLongInnerAliasBoundedWStringHelper"); + uint32_t type_size = MapULongLongInnerAliasBoundedWStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongInnerAliasBoundedWStringHelperPubSubType::~MapULongLongInnerAliasBoundedWStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongInnerAliasBoundedWStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -28268,16 +26363,12 @@ bool MapULongLongInnerAliasBoundedWStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongInnerAliasBoundedWStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -28286,18 +26377,14 @@ bool MapULongLongInnerAliasBoundedWStringHelperPubSubType::deserialize( MapULongLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -28310,52 +26397,62 @@ bool MapULongLongInnerAliasBoundedWStringHelperPubSubType::deserialize( return true; } -std::function MapULongLongInnerAliasBoundedWStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongInnerAliasBoundedWStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongInnerAliasBoundedWStringHelperPubSubType::createData() +void* MapULongLongInnerAliasBoundedWStringHelperPubSubType::create_data() { return reinterpret_cast(new MapULongLongInnerAliasBoundedWStringHelper()); } -void MapULongLongInnerAliasBoundedWStringHelperPubSubType::deleteData( +void MapULongLongInnerAliasBoundedWStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongInnerAliasBoundedWStringHelperPubSubType::getKey( +bool MapULongLongInnerAliasBoundedWStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongInnerAliasBoundedWStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongInnerAliasBoundedWStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -28363,35 +26460,27 @@ bool MapULongLongInnerAliasBoundedWStringHelperPubSubType::getKey( const MapULongLongInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -28404,49 +26493,42 @@ void MapULongLongInnerAliasBoundedWStringHelperPubSubType::register_type_object_ MapULongLongInnerEnumHelperPubSubType::MapULongLongInnerEnumHelperPubSubType() { - setName("MapULongLongInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerEnumHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerEnumHelper_max_cdr_typesize; -#endif + set_name("MapULongLongInnerEnumHelper"); + uint32_t type_size = MapULongLongInnerEnumHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerEnumHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongInnerEnumHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongInnerEnumHelperPubSubType::~MapULongLongInnerEnumHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongInnerEnumHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -28461,16 +26543,12 @@ bool MapULongLongInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -28479,18 +26557,14 @@ bool MapULongLongInnerEnumHelperPubSubType::deserialize( MapULongLongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -28503,52 +26577,62 @@ bool MapULongLongInnerEnumHelperPubSubType::deserialize( return true; } -std::function MapULongLongInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongInnerEnumHelperPubSubType::createData() +void* MapULongLongInnerEnumHelperPubSubType::create_data() { return reinterpret_cast(new MapULongLongInnerEnumHelper()); } -void MapULongLongInnerEnumHelperPubSubType::deleteData( +void MapULongLongInnerEnumHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongInnerEnumHelperPubSubType::getKey( +bool MapULongLongInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -28556,35 +26640,27 @@ bool MapULongLongInnerEnumHelperPubSubType::getKey( const MapULongLongInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -28597,49 +26673,42 @@ void MapULongLongInnerEnumHelperPubSubType::register_type_object_representation( MapULongLongInnerBitMaskHelperPubSubType::MapULongLongInnerBitMaskHelperPubSubType() { - setName("MapULongLongInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerBitMaskHelper_max_cdr_typesize; -#endif + set_name("MapULongLongInnerBitMaskHelper"); + uint32_t type_size = MapULongLongInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongInnerBitMaskHelperPubSubType::~MapULongLongInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -28654,16 +26723,12 @@ bool MapULongLongInnerBitMaskHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -28672,18 +26737,14 @@ bool MapULongLongInnerBitMaskHelperPubSubType::deserialize( MapULongLongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -28696,52 +26757,62 @@ bool MapULongLongInnerBitMaskHelperPubSubType::deserialize( return true; } -std::function MapULongLongInnerBitMaskHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongInnerBitMaskHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongInnerBitMaskHelperPubSubType::createData() +void* MapULongLongInnerBitMaskHelperPubSubType::create_data() { return reinterpret_cast(new MapULongLongInnerBitMaskHelper()); } -void MapULongLongInnerBitMaskHelperPubSubType::deleteData( +void MapULongLongInnerBitMaskHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongInnerBitMaskHelperPubSubType::getKey( +bool MapULongLongInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongInnerBitMaskHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -28749,35 +26820,27 @@ bool MapULongLongInnerBitMaskHelperPubSubType::getKey( const MapULongLongInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongInnerBitMaskHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongInnerBitMaskHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -28790,49 +26853,42 @@ void MapULongLongInnerBitMaskHelperPubSubType::register_type_object_representati MapULongLongInnerAliasHelperPubSubType::MapULongLongInnerAliasHelperPubSubType() { - setName("MapULongLongInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerAliasHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerAliasHelper_max_cdr_typesize; -#endif + set_name("MapULongLongInnerAliasHelper"); + uint32_t type_size = MapULongLongInnerAliasHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerAliasHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongInnerAliasHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongInnerAliasHelperPubSubType::~MapULongLongInnerAliasHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongInnerAliasHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -28847,16 +26903,12 @@ bool MapULongLongInnerAliasHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -28865,18 +26917,14 @@ bool MapULongLongInnerAliasHelperPubSubType::deserialize( MapULongLongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -28889,52 +26937,62 @@ bool MapULongLongInnerAliasHelperPubSubType::deserialize( return true; } -std::function MapULongLongInnerAliasHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongInnerAliasHelperPubSubType::createData() +void* MapULongLongInnerAliasHelperPubSubType::create_data() { return reinterpret_cast(new MapULongLongInnerAliasHelper()); } -void MapULongLongInnerAliasHelperPubSubType::deleteData( +void MapULongLongInnerAliasHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongInnerAliasHelperPubSubType::getKey( +bool MapULongLongInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -28942,35 +27000,27 @@ bool MapULongLongInnerAliasHelperPubSubType::getKey( const MapULongLongInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -28983,49 +27033,42 @@ void MapULongLongInnerAliasHelperPubSubType::register_type_object_representation MapULongLongInnerAliasArrayHelperPubSubType::MapULongLongInnerAliasArrayHelperPubSubType() { - setName("MapULongLongInnerAliasArrayHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerAliasArrayHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerAliasArrayHelper_max_cdr_typesize; -#endif + set_name("MapULongLongInnerAliasArrayHelper"); + uint32_t type_size = MapULongLongInnerAliasArrayHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasArrayHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasArrayHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongInnerAliasArrayHelperPubSubType::~MapULongLongInnerAliasArrayHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongInnerAliasArrayHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -29040,16 +27083,12 @@ bool MapULongLongInnerAliasArrayHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongInnerAliasArrayHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -29058,18 +27097,14 @@ bool MapULongLongInnerAliasArrayHelperPubSubType::deserialize( MapULongLongInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -29082,52 +27117,62 @@ bool MapULongLongInnerAliasArrayHelperPubSubType::deserialize( return true; } -std::function MapULongLongInnerAliasArrayHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongInnerAliasArrayHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongInnerAliasArrayHelperPubSubType::createData() +void* MapULongLongInnerAliasArrayHelperPubSubType::create_data() { return reinterpret_cast(new MapULongLongInnerAliasArrayHelper()); } -void MapULongLongInnerAliasArrayHelperPubSubType::deleteData( +void MapULongLongInnerAliasArrayHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongInnerAliasArrayHelperPubSubType::getKey( +bool MapULongLongInnerAliasArrayHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongInnerAliasArrayHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongInnerAliasArrayHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -29135,35 +27180,27 @@ bool MapULongLongInnerAliasArrayHelperPubSubType::getKey( const MapULongLongInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongInnerAliasArrayHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongInnerAliasArrayHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -29176,49 +27213,42 @@ void MapULongLongInnerAliasArrayHelperPubSubType::register_type_object_represent MapULongLongInnerAliasSequenceHelperPubSubType::MapULongLongInnerAliasSequenceHelperPubSubType() { - setName("MapULongLongInnerAliasSequenceHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerAliasSequenceHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerAliasSequenceHelper_max_cdr_typesize; -#endif + set_name("MapULongLongInnerAliasSequenceHelper"); + uint32_t type_size = MapULongLongInnerAliasSequenceHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasSequenceHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasSequenceHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongInnerAliasSequenceHelperPubSubType::~MapULongLongInnerAliasSequenceHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongInnerAliasSequenceHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -29233,16 +27263,12 @@ bool MapULongLongInnerAliasSequenceHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongInnerAliasSequenceHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -29251,18 +27277,14 @@ bool MapULongLongInnerAliasSequenceHelperPubSubType::deserialize( MapULongLongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -29275,336 +27297,138 @@ bool MapULongLongInnerAliasSequenceHelperPubSubType::deserialize( return true; } -std::function MapULongLongInnerAliasSequenceHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongInnerAliasSequenceHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapULongLongInnerAliasSequenceHelperPubSubType::createData() -{ - return reinterpret_cast(new MapULongLongInnerAliasSequenceHelper()); -} - -void MapULongLongInnerAliasSequenceHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapULongLongInnerAliasSequenceHelperPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapULongLongInnerAliasSequenceHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapULongLongInnerAliasSequenceHelper_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapULongLongInnerAliasSequenceHelper_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapULongLongInnerAliasSequenceHelperPubSubType::register_type_object_representation() -{ - register_MapULongLongInnerAliasSequenceHelper_type_identifier(type_identifiers_); } -MapULongLongInnerAliasMapHelperPubSubType::MapULongLongInnerAliasMapHelperPubSubType() +void* MapULongLongInnerAliasSequenceHelperPubSubType::create_data() { - setName("MapULongLongInnerAliasMapHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerAliasMapHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerAliasMapHelper_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasMapHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapULongLongInnerAliasSequenceHelper()); } -MapULongLongInnerAliasMapHelperPubSubType::~MapULongLongInnerAliasMapHelperPubSubType() +void MapULongLongInnerAliasSequenceHelperPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapULongLongInnerAliasMapHelperPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapULongLongInnerAliasSequenceHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapULongLongInnerAliasMapHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapULongLongInnerAliasMapHelperPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapULongLongInnerAliasMapHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapULongLongInnerAliasSequenceHelper data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapULongLongInnerAliasMapHelperPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapULongLongInnerAliasMapHelperPubSubType::createData() -{ - return reinterpret_cast(new MapULongLongInnerAliasMapHelper()); -} - -void MapULongLongInnerAliasMapHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapULongLongInnerAliasMapHelperPubSubType::getKey( +bool MapULongLongInnerAliasSequenceHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapULongLongInnerAliasMapHelper* p_type = static_cast(data); + const MapULongLongInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapULongLongInnerAliasMapHelper_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapULongLongInnerAliasSequenceHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapULongLongInnerAliasMapHelper_max_key_cdr_typesize > 16) + if (force_md5 || MapULongLongInnerAliasSequenceHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapULongLongInnerAliasMapHelperPubSubType::register_type_object_representation() +void MapULongLongInnerAliasSequenceHelperPubSubType::register_type_object_representation() { - register_MapULongLongInnerAliasMapHelper_type_identifier(type_identifiers_); + register_MapULongLongInnerAliasSequenceHelper_type_identifier(type_identifiers_); } -MapULongLongInnerUnionHelperPubSubType::MapULongLongInnerUnionHelperPubSubType() +MapULongLongInnerAliasMapHelperPubSubType::MapULongLongInnerAliasMapHelperPubSubType() { - setName("MapULongLongInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerUnionHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerUnionHelper_max_cdr_typesize; -#endif + set_name("MapULongLongInnerAliasMapHelper"); + uint32_t type_size = MapULongLongInnerAliasMapHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerUnionHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerAliasMapHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapULongLongInnerUnionHelperPubSubType::~MapULongLongInnerUnionHelperPubSubType() +MapULongLongInnerAliasMapHelperPubSubType::~MapULongLongInnerAliasMapHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapULongLongInnerUnionHelperPubSubType::serialize( +bool MapULongLongInnerAliasMapHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapULongLongInnerUnionHelper* p_type = static_cast(data); + const MapULongLongInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -29619,16 +27443,192 @@ bool MapULongLongInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapULongLongInnerAliasMapHelperPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapULongLongInnerAliasMapHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapULongLongInnerAliasMapHelperPubSubType::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* MapULongLongInnerAliasMapHelperPubSubType::create_data() +{ + return reinterpret_cast(new MapULongLongInnerAliasMapHelper()); +} + +void MapULongLongInnerAliasMapHelperPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapULongLongInnerAliasMapHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongInnerAliasMapHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongInnerAliasMapHelperPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapULongLongInnerAliasMapHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapULongLongInnerAliasMapHelper_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapULongLongInnerAliasMapHelper_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 MapULongLongInnerAliasMapHelperPubSubType::register_type_object_representation() +{ + register_MapULongLongInnerAliasMapHelper_type_identifier(type_identifiers_); +} + +MapULongLongInnerUnionHelperPubSubType::MapULongLongInnerUnionHelperPubSubType() +{ + set_name("MapULongLongInnerUnionHelper"); + uint32_t type_size = MapULongLongInnerUnionHelper_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 = MapULongLongInnerUnionHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapULongLongInnerUnionHelperPubSubType::~MapULongLongInnerUnionHelperPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapULongLongInnerUnionHelperPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapULongLongInnerUnionHelper* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -29637,18 +27637,14 @@ bool MapULongLongInnerUnionHelperPubSubType::deserialize( MapULongLongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -29661,52 +27657,62 @@ bool MapULongLongInnerUnionHelperPubSubType::deserialize( return true; } -std::function MapULongLongInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongInnerUnionHelperPubSubType::createData() +void* MapULongLongInnerUnionHelperPubSubType::create_data() { return reinterpret_cast(new MapULongLongInnerUnionHelper()); } -void MapULongLongInnerUnionHelperPubSubType::deleteData( +void MapULongLongInnerUnionHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongInnerUnionHelperPubSubType::getKey( +bool MapULongLongInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -29714,35 +27720,27 @@ bool MapULongLongInnerUnionHelperPubSubType::getKey( const MapULongLongInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -29755,49 +27753,42 @@ void MapULongLongInnerUnionHelperPubSubType::register_type_object_representation MapULongLongInnerStructureHelperPubSubType::MapULongLongInnerStructureHelperPubSubType() { - setName("MapULongLongInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerStructureHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerStructureHelper_max_cdr_typesize; -#endif + set_name("MapULongLongInnerStructureHelper"); + uint32_t type_size = MapULongLongInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerStructureHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongInnerStructureHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongInnerStructureHelperPubSubType::~MapULongLongInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -29812,16 +27803,12 @@ bool MapULongLongInnerStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -29830,18 +27817,14 @@ bool MapULongLongInnerStructureHelperPubSubType::deserialize( MapULongLongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -29854,52 +27837,62 @@ bool MapULongLongInnerStructureHelperPubSubType::deserialize( return true; } -std::function MapULongLongInnerStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongInnerStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongInnerStructureHelperPubSubType::createData() +void* MapULongLongInnerStructureHelperPubSubType::create_data() { return reinterpret_cast(new MapULongLongInnerStructureHelper()); } -void MapULongLongInnerStructureHelperPubSubType::deleteData( +void MapULongLongInnerStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongInnerStructureHelperPubSubType::getKey( +bool MapULongLongInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongInnerStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -29907,35 +27900,27 @@ bool MapULongLongInnerStructureHelperPubSubType::getKey( const MapULongLongInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongInnerStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongInnerStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -29948,49 +27933,42 @@ void MapULongLongInnerStructureHelperPubSubType::register_type_object_representa MapULongLongInnerBitsetHelperPubSubType::MapULongLongInnerBitsetHelperPubSubType() { - setName("MapULongLongInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapULongLongInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - MapULongLongInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("MapULongLongInnerBitsetHelper"); + uint32_t type_size = MapULongLongInnerBitsetHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapULongLongInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapULongLongInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapULongLongInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapULongLongInnerBitsetHelperPubSubType::~MapULongLongInnerBitsetHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapULongLongInnerBitsetHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapULongLongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -30005,16 +27983,12 @@ bool MapULongLongInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapULongLongInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -30023,18 +27997,14 @@ bool MapULongLongInnerBitsetHelperPubSubType::deserialize( MapULongLongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -30047,52 +28017,62 @@ bool MapULongLongInnerBitsetHelperPubSubType::deserialize( return true; } -std::function MapULongLongInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t MapULongLongInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapULongLongInnerBitsetHelperPubSubType::createData() +void* MapULongLongInnerBitsetHelperPubSubType::create_data() { return reinterpret_cast(new MapULongLongInnerBitsetHelper()); } -void MapULongLongInnerBitsetHelperPubSubType::deleteData( +void MapULongLongInnerBitsetHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapULongLongInnerBitsetHelperPubSubType::getKey( +bool MapULongLongInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapULongLongInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapULongLongInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -30100,35 +28080,27 @@ bool MapULongLongInnerBitsetHelperPubSubType::getKey( const MapULongLongInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapULongLongInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapULongLongInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -30141,49 +28113,42 @@ void MapULongLongInnerBitsetHelperPubSubType::register_type_object_representatio MapStringShortPubSubType::MapStringShortPubSubType() { - setName("MapStringShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringShort::getMaxCdrSerializedSize()); -#else - MapStringShort_max_cdr_typesize; -#endif + set_name("MapStringShort"); + uint32_t type_size = MapStringShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringShort_max_key_cdr_typesize > 16 ? MapStringShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringShort_max_key_cdr_typesize > 16 ? MapStringShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringShortPubSubType::~MapStringShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -30198,16 +28163,12 @@ bool MapStringShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -30216,18 +28177,14 @@ bool MapStringShortPubSubType::deserialize( MapStringShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -30240,52 +28197,62 @@ bool MapStringShortPubSubType::deserialize( return true; } -std::function MapStringShortPubSubType::getSerializedSizeProvider( +uint32_t MapStringShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringShortPubSubType::createData() +void* MapStringShortPubSubType::create_data() { return reinterpret_cast(new MapStringShort()); } -void MapStringShortPubSubType::deleteData( +void MapStringShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringShortPubSubType::getKey( +bool MapStringShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -30293,35 +28260,27 @@ bool MapStringShortPubSubType::getKey( const MapStringShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -30334,49 +28293,42 @@ void MapStringShortPubSubType::register_type_object_representation() MapStringUShortPubSubType::MapStringUShortPubSubType() { - setName("MapStringUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringUShort::getMaxCdrSerializedSize()); -#else - MapStringUShort_max_cdr_typesize; -#endif + set_name("MapStringUShort"); + uint32_t type_size = MapStringUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringUShort_max_key_cdr_typesize > 16 ? MapStringUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringUShort_max_key_cdr_typesize > 16 ? MapStringUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringUShortPubSubType::~MapStringUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -30391,16 +28343,12 @@ bool MapStringUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -30409,18 +28357,14 @@ bool MapStringUShortPubSubType::deserialize( MapStringUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -30433,52 +28377,62 @@ bool MapStringUShortPubSubType::deserialize( return true; } -std::function MapStringUShortPubSubType::getSerializedSizeProvider( +uint32_t MapStringUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringUShortPubSubType::createData() +void* MapStringUShortPubSubType::create_data() { return reinterpret_cast(new MapStringUShort()); } -void MapStringUShortPubSubType::deleteData( +void MapStringUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringUShortPubSubType::getKey( +bool MapStringUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -30486,35 +28440,27 @@ bool MapStringUShortPubSubType::getKey( const MapStringUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -30527,49 +28473,42 @@ void MapStringUShortPubSubType::register_type_object_representation() MapStringLongPubSubType::MapStringLongPubSubType() { - setName("MapStringLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringLong::getMaxCdrSerializedSize()); -#else - MapStringLong_max_cdr_typesize; -#endif + set_name("MapStringLong"); + uint32_t type_size = MapStringLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringLong_max_key_cdr_typesize > 16 ? MapStringLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringLong_max_key_cdr_typesize > 16 ? MapStringLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringLongPubSubType::~MapStringLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -30584,16 +28523,12 @@ bool MapStringLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -30602,18 +28537,14 @@ bool MapStringLongPubSubType::deserialize( MapStringLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -30626,52 +28557,62 @@ bool MapStringLongPubSubType::deserialize( return true; } -std::function MapStringLongPubSubType::getSerializedSizeProvider( +uint32_t MapStringLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringLongPubSubType::createData() +void* MapStringLongPubSubType::create_data() { return reinterpret_cast(new MapStringLong()); } -void MapStringLongPubSubType::deleteData( +void MapStringLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringLongPubSubType::getKey( +bool MapStringLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -30679,35 +28620,27 @@ bool MapStringLongPubSubType::getKey( const MapStringLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -30720,49 +28653,42 @@ void MapStringLongPubSubType::register_type_object_representation() MapStringULongPubSubType::MapStringULongPubSubType() { - setName("MapStringULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringULong::getMaxCdrSerializedSize()); -#else - MapStringULong_max_cdr_typesize; -#endif + set_name("MapStringULong"); + uint32_t type_size = MapStringULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringULong_max_key_cdr_typesize > 16 ? MapStringULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringULong_max_key_cdr_typesize > 16 ? MapStringULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringULongPubSubType::~MapStringULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -30777,16 +28703,12 @@ bool MapStringULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -30795,18 +28717,14 @@ bool MapStringULongPubSubType::deserialize( MapStringULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -30819,52 +28737,62 @@ bool MapStringULongPubSubType::deserialize( return true; } -std::function MapStringULongPubSubType::getSerializedSizeProvider( +uint32_t MapStringULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringULongPubSubType::createData() +void* MapStringULongPubSubType::create_data() { return reinterpret_cast(new MapStringULong()); } -void MapStringULongPubSubType::deleteData( +void MapStringULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringULongPubSubType::getKey( +bool MapStringULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -30872,35 +28800,27 @@ bool MapStringULongPubSubType::getKey( const MapStringULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -30913,49 +28833,42 @@ void MapStringULongPubSubType::register_type_object_representation() MapStringLongLongPubSubType::MapStringLongLongPubSubType() { - setName("MapStringLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringLongLong::getMaxCdrSerializedSize()); -#else - MapStringLongLong_max_cdr_typesize; -#endif + set_name("MapStringLongLong"); + uint32_t type_size = MapStringLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringLongLong_max_key_cdr_typesize > 16 ? MapStringLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringLongLong_max_key_cdr_typesize > 16 ? MapStringLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringLongLongPubSubType::~MapStringLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -30970,16 +28883,12 @@ bool MapStringLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -30988,18 +28897,14 @@ bool MapStringLongLongPubSubType::deserialize( MapStringLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -31012,52 +28917,62 @@ bool MapStringLongLongPubSubType::deserialize( return true; } -std::function MapStringLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapStringLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringLongLongPubSubType::createData() +void* MapStringLongLongPubSubType::create_data() { return reinterpret_cast(new MapStringLongLong()); } -void MapStringLongLongPubSubType::deleteData( +void MapStringLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringLongLongPubSubType::getKey( +bool MapStringLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -31065,35 +28980,27 @@ bool MapStringLongLongPubSubType::getKey( const MapStringLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -31106,49 +29013,42 @@ void MapStringLongLongPubSubType::register_type_object_representation() MapStringULongLongPubSubType::MapStringULongLongPubSubType() { - setName("MapStringULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringULongLong::getMaxCdrSerializedSize()); -#else - MapStringULongLong_max_cdr_typesize; -#endif + set_name("MapStringULongLong"); + uint32_t type_size = MapStringULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringULongLong_max_key_cdr_typesize > 16 ? MapStringULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringULongLong_max_key_cdr_typesize > 16 ? MapStringULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringULongLongPubSubType::~MapStringULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -31163,16 +29063,12 @@ bool MapStringULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -31181,18 +29077,14 @@ bool MapStringULongLongPubSubType::deserialize( MapStringULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -31205,52 +29097,62 @@ bool MapStringULongLongPubSubType::deserialize( return true; } -std::function MapStringULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapStringULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringULongLongPubSubType::createData() +void* MapStringULongLongPubSubType::create_data() { return reinterpret_cast(new MapStringULongLong()); } -void MapStringULongLongPubSubType::deleteData( +void MapStringULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringULongLongPubSubType::getKey( +bool MapStringULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -31258,35 +29160,27 @@ bool MapStringULongLongPubSubType::getKey( const MapStringULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -31299,49 +29193,42 @@ void MapStringULongLongPubSubType::register_type_object_representation() MapStringFloatPubSubType::MapStringFloatPubSubType() { - setName("MapStringFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringFloat::getMaxCdrSerializedSize()); -#else - MapStringFloat_max_cdr_typesize; -#endif + set_name("MapStringFloat"); + uint32_t type_size = MapStringFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringFloat_max_key_cdr_typesize > 16 ? MapStringFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringFloat_max_key_cdr_typesize > 16 ? MapStringFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringFloatPubSubType::~MapStringFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -31356,16 +29243,12 @@ bool MapStringFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -31374,18 +29257,14 @@ bool MapStringFloatPubSubType::deserialize( MapStringFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -31398,52 +29277,62 @@ bool MapStringFloatPubSubType::deserialize( return true; } -std::function MapStringFloatPubSubType::getSerializedSizeProvider( +uint32_t MapStringFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringFloatPubSubType::createData() +void* MapStringFloatPubSubType::create_data() { return reinterpret_cast(new MapStringFloat()); } -void MapStringFloatPubSubType::deleteData( +void MapStringFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringFloatPubSubType::getKey( +bool MapStringFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -31451,35 +29340,27 @@ bool MapStringFloatPubSubType::getKey( const MapStringFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -31492,49 +29373,42 @@ void MapStringFloatPubSubType::register_type_object_representation() MapStringDoublePubSubType::MapStringDoublePubSubType() { - setName("MapStringDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringDouble::getMaxCdrSerializedSize()); -#else - MapStringDouble_max_cdr_typesize; -#endif + set_name("MapStringDouble"); + uint32_t type_size = MapStringDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringDouble_max_key_cdr_typesize > 16 ? MapStringDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringDouble_max_key_cdr_typesize > 16 ? MapStringDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringDoublePubSubType::~MapStringDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -31549,16 +29423,12 @@ bool MapStringDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -31567,18 +29437,14 @@ bool MapStringDoublePubSubType::deserialize( MapStringDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -31591,52 +29457,62 @@ bool MapStringDoublePubSubType::deserialize( return true; } -std::function MapStringDoublePubSubType::getSerializedSizeProvider( +uint32_t MapStringDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringDoublePubSubType::createData() +void* MapStringDoublePubSubType::create_data() { return reinterpret_cast(new MapStringDouble()); } -void MapStringDoublePubSubType::deleteData( +void MapStringDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringDoublePubSubType::getKey( +bool MapStringDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -31644,35 +29520,27 @@ bool MapStringDoublePubSubType::getKey( const MapStringDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -31685,49 +29553,42 @@ void MapStringDoublePubSubType::register_type_object_representation() MapStringLongDoublePubSubType::MapStringLongDoublePubSubType() { - setName("MapStringLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringLongDouble::getMaxCdrSerializedSize()); -#else - MapStringLongDouble_max_cdr_typesize; -#endif + set_name("MapStringLongDouble"); + uint32_t type_size = MapStringLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringLongDouble_max_key_cdr_typesize > 16 ? MapStringLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringLongDouble_max_key_cdr_typesize > 16 ? MapStringLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringLongDoublePubSubType::~MapStringLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -31742,16 +29603,12 @@ bool MapStringLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -31760,18 +29617,14 @@ bool MapStringLongDoublePubSubType::deserialize( MapStringLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -31784,52 +29637,62 @@ bool MapStringLongDoublePubSubType::deserialize( return true; } -std::function MapStringLongDoublePubSubType::getSerializedSizeProvider( +uint32_t MapStringLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringLongDoublePubSubType::createData() +void* MapStringLongDoublePubSubType::create_data() { return reinterpret_cast(new MapStringLongDouble()); } -void MapStringLongDoublePubSubType::deleteData( +void MapStringLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringLongDoublePubSubType::getKey( +bool MapStringLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -31837,35 +29700,27 @@ bool MapStringLongDoublePubSubType::getKey( const MapStringLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -31878,49 +29733,42 @@ void MapStringLongDoublePubSubType::register_type_object_representation() MapStringBooleanPubSubType::MapStringBooleanPubSubType() { - setName("MapStringBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringBoolean::getMaxCdrSerializedSize()); -#else - MapStringBoolean_max_cdr_typesize; -#endif + set_name("MapStringBoolean"); + uint32_t type_size = MapStringBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringBoolean_max_key_cdr_typesize > 16 ? MapStringBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringBoolean_max_key_cdr_typesize > 16 ? MapStringBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringBooleanPubSubType::~MapStringBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -31935,16 +29783,12 @@ bool MapStringBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -31953,18 +29797,14 @@ bool MapStringBooleanPubSubType::deserialize( MapStringBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -31977,52 +29817,62 @@ bool MapStringBooleanPubSubType::deserialize( return true; } -std::function MapStringBooleanPubSubType::getSerializedSizeProvider( +uint32_t MapStringBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringBooleanPubSubType::createData() +void* MapStringBooleanPubSubType::create_data() { return reinterpret_cast(new MapStringBoolean()); } -void MapStringBooleanPubSubType::deleteData( +void MapStringBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringBooleanPubSubType::getKey( +bool MapStringBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -32030,35 +29880,27 @@ bool MapStringBooleanPubSubType::getKey( const MapStringBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -32071,49 +29913,42 @@ void MapStringBooleanPubSubType::register_type_object_representation() MapStringOctetPubSubType::MapStringOctetPubSubType() { - setName("MapStringOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringOctet::getMaxCdrSerializedSize()); -#else - MapStringOctet_max_cdr_typesize; -#endif + set_name("MapStringOctet"); + uint32_t type_size = MapStringOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringOctet_max_key_cdr_typesize > 16 ? MapStringOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringOctet_max_key_cdr_typesize > 16 ? MapStringOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringOctetPubSubType::~MapStringOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -32128,16 +29963,12 @@ bool MapStringOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -32146,18 +29977,14 @@ bool MapStringOctetPubSubType::deserialize( MapStringOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -32170,52 +29997,62 @@ bool MapStringOctetPubSubType::deserialize( return true; } -std::function MapStringOctetPubSubType::getSerializedSizeProvider( +uint32_t MapStringOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringOctetPubSubType::createData() +void* MapStringOctetPubSubType::create_data() { return reinterpret_cast(new MapStringOctet()); } -void MapStringOctetPubSubType::deleteData( +void MapStringOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringOctetPubSubType::getKey( +bool MapStringOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -32223,35 +30060,27 @@ bool MapStringOctetPubSubType::getKey( const MapStringOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -32264,49 +30093,42 @@ void MapStringOctetPubSubType::register_type_object_representation() MapStringCharPubSubType::MapStringCharPubSubType() { - setName("MapStringChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringChar::getMaxCdrSerializedSize()); -#else - MapStringChar_max_cdr_typesize; -#endif + set_name("MapStringChar"); + uint32_t type_size = MapStringChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringChar_max_key_cdr_typesize > 16 ? MapStringChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringChar_max_key_cdr_typesize > 16 ? MapStringChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringCharPubSubType::~MapStringCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -32321,16 +30143,12 @@ bool MapStringCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -32339,18 +30157,14 @@ bool MapStringCharPubSubType::deserialize( MapStringChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -32363,336 +30177,138 @@ bool MapStringCharPubSubType::deserialize( return true; } -std::function MapStringCharPubSubType::getSerializedSizeProvider( +uint32_t MapStringCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapStringCharPubSubType::createData() -{ - return reinterpret_cast(new MapStringChar()); -} - -void MapStringCharPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapStringCharPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapStringChar* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapStringChar_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapStringChar_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapStringCharPubSubType::register_type_object_representation() -{ - register_MapStringChar_type_identifier(type_identifiers_); } -MapStringWCharPubSubType::MapStringWCharPubSubType() +void* MapStringCharPubSubType::create_data() { - setName("MapStringWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringWChar::getMaxCdrSerializedSize()); -#else - MapStringWChar_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringWChar_max_key_cdr_typesize > 16 ? MapStringWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapStringChar()); } -MapStringWCharPubSubType::~MapStringWCharPubSubType() +void MapStringCharPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapStringWCharPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapStringCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapStringWChar* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapStringWCharPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapStringWChar* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapStringChar data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapStringWCharPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapStringWCharPubSubType::createData() -{ - return reinterpret_cast(new MapStringWChar()); -} - -void MapStringWCharPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapStringWCharPubSubType::getKey( +bool MapStringCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapStringWChar* p_type = static_cast(data); + const MapStringChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapStringWChar_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapStringChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapStringWChar_max_key_cdr_typesize > 16) + if (force_md5 || MapStringChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapStringWCharPubSubType::register_type_object_representation() +void MapStringCharPubSubType::register_type_object_representation() { - register_MapStringWChar_type_identifier(type_identifiers_); + register_MapStringChar_type_identifier(type_identifiers_); } -MapStringStringPubSubType::MapStringStringPubSubType() +MapStringWCharPubSubType::MapStringWCharPubSubType() { - setName("MapStringString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringString::getMaxCdrSerializedSize()); -#else - MapStringString_max_cdr_typesize; -#endif + set_name("MapStringWChar"); + uint32_t type_size = MapStringWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringString_max_key_cdr_typesize > 16 ? MapStringString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringWChar_max_key_cdr_typesize > 16 ? MapStringWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapStringStringPubSubType::~MapStringStringPubSubType() +MapStringWCharPubSubType::~MapStringWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapStringStringPubSubType::serialize( +bool MapStringWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapStringString* p_type = static_cast(data); + const MapStringWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -32707,16 +30323,192 @@ bool MapStringStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapStringWCharPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapStringWChar* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapStringWCharPubSubType::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* MapStringWCharPubSubType::create_data() +{ + return reinterpret_cast(new MapStringWChar()); +} + +void MapStringWCharPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapStringWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringWCharPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapStringWChar* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapStringWChar_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapStringWChar_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 MapStringWCharPubSubType::register_type_object_representation() +{ + register_MapStringWChar_type_identifier(type_identifiers_); +} + +MapStringStringPubSubType::MapStringStringPubSubType() +{ + set_name("MapStringString"); + uint32_t type_size = MapStringString_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 = MapStringString_max_key_cdr_typesize > 16 ? MapStringString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapStringStringPubSubType::~MapStringStringPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapStringStringPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapStringString* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -32725,18 +30517,14 @@ bool MapStringStringPubSubType::deserialize( MapStringString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -32749,52 +30537,62 @@ bool MapStringStringPubSubType::deserialize( return true; } -std::function MapStringStringPubSubType::getSerializedSizeProvider( +uint32_t MapStringStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringStringPubSubType::createData() +void* MapStringStringPubSubType::create_data() { return reinterpret_cast(new MapStringString()); } -void MapStringStringPubSubType::deleteData( +void MapStringStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringStringPubSubType::getKey( +bool MapStringStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -32802,35 +30600,27 @@ bool MapStringStringPubSubType::getKey( const MapStringString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -32843,49 +30633,42 @@ void MapStringStringPubSubType::register_type_object_representation() MapStringWStringPubSubType::MapStringWStringPubSubType() { - setName("MapStringWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringWString::getMaxCdrSerializedSize()); -#else - MapStringWString_max_cdr_typesize; -#endif + set_name("MapStringWString"); + uint32_t type_size = MapStringWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringWString_max_key_cdr_typesize > 16 ? MapStringWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringWString_max_key_cdr_typesize > 16 ? MapStringWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringWStringPubSubType::~MapStringWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -32900,16 +30683,12 @@ bool MapStringWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -32918,18 +30697,14 @@ bool MapStringWStringPubSubType::deserialize( MapStringWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -32942,52 +30717,62 @@ bool MapStringWStringPubSubType::deserialize( return true; } -std::function MapStringWStringPubSubType::getSerializedSizeProvider( +uint32_t MapStringWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringWStringPubSubType::createData() +void* MapStringWStringPubSubType::create_data() { return reinterpret_cast(new MapStringWString()); } -void MapStringWStringPubSubType::deleteData( +void MapStringWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringWStringPubSubType::getKey( +bool MapStringWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -32995,35 +30780,27 @@ bool MapStringWStringPubSubType::getKey( const MapStringWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -33036,49 +30813,42 @@ void MapStringWStringPubSubType::register_type_object_representation() MapStringInnerAliasBoundedStringHelperPubSubType::MapStringInnerAliasBoundedStringHelperPubSubType() { - setName("MapStringInnerAliasBoundedStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerAliasBoundedStringHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerAliasBoundedStringHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerAliasBoundedStringHelper"); + uint32_t type_size = MapStringInnerAliasBoundedStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerAliasBoundedStringHelperPubSubType::~MapStringInnerAliasBoundedStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerAliasBoundedStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -33093,16 +30863,12 @@ bool MapStringInnerAliasBoundedStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerAliasBoundedStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -33111,18 +30877,14 @@ bool MapStringInnerAliasBoundedStringHelperPubSubType::deserialize( MapStringInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -33135,52 +30897,62 @@ bool MapStringInnerAliasBoundedStringHelperPubSubType::deserialize( return true; } -std::function MapStringInnerAliasBoundedStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerAliasBoundedStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerAliasBoundedStringHelperPubSubType::createData() +void* MapStringInnerAliasBoundedStringHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerAliasBoundedStringHelper()); } -void MapStringInnerAliasBoundedStringHelperPubSubType::deleteData( +void MapStringInnerAliasBoundedStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerAliasBoundedStringHelperPubSubType::getKey( +bool MapStringInnerAliasBoundedStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerAliasBoundedStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerAliasBoundedStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -33188,35 +30960,27 @@ bool MapStringInnerAliasBoundedStringHelperPubSubType::getKey( const MapStringInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerAliasBoundedStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -33229,49 +30993,42 @@ void MapStringInnerAliasBoundedStringHelperPubSubType::register_type_object_repr MapStringInnerAliasBoundedWStringHelperPubSubType::MapStringInnerAliasBoundedWStringHelperPubSubType() { - setName("MapStringInnerAliasBoundedWStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerAliasBoundedWStringHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerAliasBoundedWStringHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerAliasBoundedWStringHelper"); + uint32_t type_size = MapStringInnerAliasBoundedWStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerAliasBoundedWStringHelperPubSubType::~MapStringInnerAliasBoundedWStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerAliasBoundedWStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -33286,16 +31043,12 @@ bool MapStringInnerAliasBoundedWStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerAliasBoundedWStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -33304,18 +31057,14 @@ bool MapStringInnerAliasBoundedWStringHelperPubSubType::deserialize( MapStringInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -33328,52 +31077,62 @@ bool MapStringInnerAliasBoundedWStringHelperPubSubType::deserialize( return true; } -std::function MapStringInnerAliasBoundedWStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerAliasBoundedWStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerAliasBoundedWStringHelperPubSubType::createData() +void* MapStringInnerAliasBoundedWStringHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerAliasBoundedWStringHelper()); } -void MapStringInnerAliasBoundedWStringHelperPubSubType::deleteData( +void MapStringInnerAliasBoundedWStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerAliasBoundedWStringHelperPubSubType::getKey( +bool MapStringInnerAliasBoundedWStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerAliasBoundedWStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerAliasBoundedWStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -33381,35 +31140,27 @@ bool MapStringInnerAliasBoundedWStringHelperPubSubType::getKey( const MapStringInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -33422,49 +31173,42 @@ void MapStringInnerAliasBoundedWStringHelperPubSubType::register_type_object_rep MapStringInnerEnumHelperPubSubType::MapStringInnerEnumHelperPubSubType() { - setName("MapStringInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerEnumHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerEnumHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerEnumHelper"); + uint32_t type_size = MapStringInnerEnumHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerEnumHelper_max_key_cdr_typesize > 16 ? MapStringInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerEnumHelper_max_key_cdr_typesize > 16 ? MapStringInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerEnumHelperPubSubType::~MapStringInnerEnumHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerEnumHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -33479,16 +31223,12 @@ bool MapStringInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -33497,18 +31237,14 @@ bool MapStringInnerEnumHelperPubSubType::deserialize( MapStringInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -33521,52 +31257,62 @@ bool MapStringInnerEnumHelperPubSubType::deserialize( return true; } -std::function MapStringInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerEnumHelperPubSubType::createData() +void* MapStringInnerEnumHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerEnumHelper()); } -void MapStringInnerEnumHelperPubSubType::deleteData( +void MapStringInnerEnumHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerEnumHelperPubSubType::getKey( +bool MapStringInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -33574,35 +31320,27 @@ bool MapStringInnerEnumHelperPubSubType::getKey( const MapStringInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -33615,49 +31353,42 @@ void MapStringInnerEnumHelperPubSubType::register_type_object_representation() MapStringInnerBitMaskHelperPubSubType::MapStringInnerBitMaskHelperPubSubType() { - setName("MapStringInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerBitMaskHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerBitMaskHelper"); + uint32_t type_size = MapStringInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapStringInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapStringInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerBitMaskHelperPubSubType::~MapStringInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -33672,16 +31403,12 @@ bool MapStringInnerBitMaskHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -33690,18 +31417,14 @@ bool MapStringInnerBitMaskHelperPubSubType::deserialize( MapStringInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -33714,52 +31437,62 @@ bool MapStringInnerBitMaskHelperPubSubType::deserialize( return true; } -std::function MapStringInnerBitMaskHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerBitMaskHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerBitMaskHelperPubSubType::createData() +void* MapStringInnerBitMaskHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerBitMaskHelper()); } -void MapStringInnerBitMaskHelperPubSubType::deleteData( +void MapStringInnerBitMaskHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerBitMaskHelperPubSubType::getKey( +bool MapStringInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerBitMaskHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -33767,35 +31500,27 @@ bool MapStringInnerBitMaskHelperPubSubType::getKey( const MapStringInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerBitMaskHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerBitMaskHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -33808,49 +31533,42 @@ void MapStringInnerBitMaskHelperPubSubType::register_type_object_representation( MapStringInnerAliasHelperPubSubType::MapStringInnerAliasHelperPubSubType() { - setName("MapStringInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerAliasHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerAliasHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerAliasHelper"); + uint32_t type_size = MapStringInnerAliasHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerAliasHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerAliasHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerAliasHelperPubSubType::~MapStringInnerAliasHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerAliasHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -33865,16 +31583,12 @@ bool MapStringInnerAliasHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -33883,18 +31597,14 @@ bool MapStringInnerAliasHelperPubSubType::deserialize( MapStringInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -33907,52 +31617,62 @@ bool MapStringInnerAliasHelperPubSubType::deserialize( return true; } -std::function MapStringInnerAliasHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerAliasHelperPubSubType::createData() +void* MapStringInnerAliasHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerAliasHelper()); } -void MapStringInnerAliasHelperPubSubType::deleteData( +void MapStringInnerAliasHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerAliasHelperPubSubType::getKey( +bool MapStringInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -33960,35 +31680,27 @@ bool MapStringInnerAliasHelperPubSubType::getKey( const MapStringInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -34001,49 +31713,42 @@ void MapStringInnerAliasHelperPubSubType::register_type_object_representation() MapStringInnerAliasArrayHelperPubSubType::MapStringInnerAliasArrayHelperPubSubType() { - setName("MapStringInnerAliasArrayHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerAliasArrayHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerAliasArrayHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerAliasArrayHelper"); + uint32_t type_size = MapStringInnerAliasArrayHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasArrayHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasArrayHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerAliasArrayHelperPubSubType::~MapStringInnerAliasArrayHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerAliasArrayHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -34058,16 +31763,12 @@ bool MapStringInnerAliasArrayHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerAliasArrayHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -34076,18 +31777,14 @@ bool MapStringInnerAliasArrayHelperPubSubType::deserialize( MapStringInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -34100,52 +31797,62 @@ bool MapStringInnerAliasArrayHelperPubSubType::deserialize( return true; } -std::function MapStringInnerAliasArrayHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerAliasArrayHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerAliasArrayHelperPubSubType::createData() +void* MapStringInnerAliasArrayHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerAliasArrayHelper()); } -void MapStringInnerAliasArrayHelperPubSubType::deleteData( +void MapStringInnerAliasArrayHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerAliasArrayHelperPubSubType::getKey( +bool MapStringInnerAliasArrayHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerAliasArrayHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerAliasArrayHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -34153,35 +31860,27 @@ bool MapStringInnerAliasArrayHelperPubSubType::getKey( const MapStringInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerAliasArrayHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerAliasArrayHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -34194,49 +31893,42 @@ void MapStringInnerAliasArrayHelperPubSubType::register_type_object_representati MapStringInnerAliasSequenceHelperPubSubType::MapStringInnerAliasSequenceHelperPubSubType() { - setName("MapStringInnerAliasSequenceHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerAliasSequenceHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerAliasSequenceHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerAliasSequenceHelper"); + uint32_t type_size = MapStringInnerAliasSequenceHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasSequenceHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasSequenceHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerAliasSequenceHelperPubSubType::~MapStringInnerAliasSequenceHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerAliasSequenceHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -34251,16 +31943,12 @@ bool MapStringInnerAliasSequenceHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerAliasSequenceHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -34269,18 +31957,14 @@ bool MapStringInnerAliasSequenceHelperPubSubType::deserialize( MapStringInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -34293,52 +31977,62 @@ bool MapStringInnerAliasSequenceHelperPubSubType::deserialize( return true; } -std::function MapStringInnerAliasSequenceHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerAliasSequenceHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerAliasSequenceHelperPubSubType::createData() +void* MapStringInnerAliasSequenceHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerAliasSequenceHelper()); } -void MapStringInnerAliasSequenceHelperPubSubType::deleteData( +void MapStringInnerAliasSequenceHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerAliasSequenceHelperPubSubType::getKey( +bool MapStringInnerAliasSequenceHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerAliasSequenceHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerAliasSequenceHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -34346,35 +32040,27 @@ bool MapStringInnerAliasSequenceHelperPubSubType::getKey( const MapStringInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerAliasSequenceHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerAliasSequenceHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -34387,49 +32073,42 @@ void MapStringInnerAliasSequenceHelperPubSubType::register_type_object_represent MapStringInnerAliasMapHelperPubSubType::MapStringInnerAliasMapHelperPubSubType() { - setName("MapStringInnerAliasMapHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerAliasMapHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerAliasMapHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerAliasMapHelper"); + uint32_t type_size = MapStringInnerAliasMapHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasMapHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapStringInnerAliasMapHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerAliasMapHelperPubSubType::~MapStringInnerAliasMapHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerAliasMapHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -34444,16 +32123,12 @@ bool MapStringInnerAliasMapHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerAliasMapHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -34462,18 +32137,14 @@ bool MapStringInnerAliasMapHelperPubSubType::deserialize( MapStringInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -34486,52 +32157,62 @@ bool MapStringInnerAliasMapHelperPubSubType::deserialize( return true; } -std::function MapStringInnerAliasMapHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerAliasMapHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerAliasMapHelperPubSubType::createData() +void* MapStringInnerAliasMapHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerAliasMapHelper()); } -void MapStringInnerAliasMapHelperPubSubType::deleteData( +void MapStringInnerAliasMapHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerAliasMapHelperPubSubType::getKey( +bool MapStringInnerAliasMapHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerAliasMapHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerAliasMapHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -34539,35 +32220,27 @@ bool MapStringInnerAliasMapHelperPubSubType::getKey( const MapStringInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerAliasMapHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerAliasMapHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -34580,49 +32253,42 @@ void MapStringInnerAliasMapHelperPubSubType::register_type_object_representation MapStringInnerUnionHelperPubSubType::MapStringInnerUnionHelperPubSubType() { - setName("MapStringInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerUnionHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerUnionHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerUnionHelper"); + uint32_t type_size = MapStringInnerUnionHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerUnionHelper_max_key_cdr_typesize > 16 ? MapStringInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerUnionHelper_max_key_cdr_typesize > 16 ? MapStringInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerUnionHelperPubSubType::~MapStringInnerUnionHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerUnionHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -34637,16 +32303,12 @@ bool MapStringInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -34655,18 +32317,14 @@ bool MapStringInnerUnionHelperPubSubType::deserialize( MapStringInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -34679,52 +32337,62 @@ bool MapStringInnerUnionHelperPubSubType::deserialize( return true; } -std::function MapStringInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerUnionHelperPubSubType::createData() +void* MapStringInnerUnionHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerUnionHelper()); } -void MapStringInnerUnionHelperPubSubType::deleteData( +void MapStringInnerUnionHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerUnionHelperPubSubType::getKey( +bool MapStringInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -34732,35 +32400,27 @@ bool MapStringInnerUnionHelperPubSubType::getKey( const MapStringInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -34773,49 +32433,42 @@ void MapStringInnerUnionHelperPubSubType::register_type_object_representation() MapStringInnerStructureHelperPubSubType::MapStringInnerStructureHelperPubSubType() { - setName("MapStringInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerStructureHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerStructureHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerStructureHelper"); + uint32_t type_size = MapStringInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerStructureHelper_max_key_cdr_typesize > 16 ? MapStringInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerStructureHelper_max_key_cdr_typesize > 16 ? MapStringInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerStructureHelperPubSubType::~MapStringInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -34830,16 +32483,12 @@ bool MapStringInnerStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -34848,18 +32497,14 @@ bool MapStringInnerStructureHelperPubSubType::deserialize( MapStringInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -34872,52 +32517,62 @@ bool MapStringInnerStructureHelperPubSubType::deserialize( return true; } -std::function MapStringInnerStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerStructureHelperPubSubType::createData() +void* MapStringInnerStructureHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerStructureHelper()); } -void MapStringInnerStructureHelperPubSubType::deleteData( +void MapStringInnerStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerStructureHelperPubSubType::getKey( +bool MapStringInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -34925,35 +32580,27 @@ bool MapStringInnerStructureHelperPubSubType::getKey( const MapStringInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -34966,49 +32613,42 @@ void MapStringInnerStructureHelperPubSubType::register_type_object_representatio MapStringInnerBitsetHelperPubSubType::MapStringInnerBitsetHelperPubSubType() { - setName("MapStringInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStringInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - MapStringInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("MapStringInnerBitsetHelper"); + uint32_t type_size = MapStringInnerBitsetHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStringInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapStringInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStringInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapStringInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStringInnerBitsetHelperPubSubType::~MapStringInnerBitsetHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStringInnerBitsetHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStringInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -35023,16 +32663,12 @@ bool MapStringInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStringInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -35041,18 +32677,14 @@ bool MapStringInnerBitsetHelperPubSubType::deserialize( MapStringInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -35065,52 +32697,62 @@ bool MapStringInnerBitsetHelperPubSubType::deserialize( return true; } -std::function MapStringInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t MapStringInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStringInnerBitsetHelperPubSubType::createData() +void* MapStringInnerBitsetHelperPubSubType::create_data() { return reinterpret_cast(new MapStringInnerBitsetHelper()); } -void MapStringInnerBitsetHelperPubSubType::deleteData( +void MapStringInnerBitsetHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStringInnerBitsetHelperPubSubType::getKey( +bool MapStringInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStringInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStringInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -35118,35 +32760,27 @@ bool MapStringInnerBitsetHelperPubSubType::getKey( const MapStringInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStringInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStringInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -35159,49 +32793,42 @@ void MapStringInnerBitsetHelperPubSubType::register_type_object_representation() MapWStringShortPubSubType::MapWStringShortPubSubType() { - setName("MapWStringShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringShort::getMaxCdrSerializedSize()); -#else - MapWStringShort_max_cdr_typesize; -#endif + set_name("MapWStringShort"); + uint32_t type_size = MapWStringShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringShort_max_key_cdr_typesize > 16 ? MapWStringShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringShort_max_key_cdr_typesize > 16 ? MapWStringShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringShortPubSubType::~MapWStringShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -35216,16 +32843,12 @@ bool MapWStringShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -35234,18 +32857,14 @@ bool MapWStringShortPubSubType::deserialize( MapWStringShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -35258,52 +32877,62 @@ bool MapWStringShortPubSubType::deserialize( return true; } -std::function MapWStringShortPubSubType::getSerializedSizeProvider( +uint32_t MapWStringShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringShortPubSubType::createData() +void* MapWStringShortPubSubType::create_data() { return reinterpret_cast(new MapWStringShort()); } -void MapWStringShortPubSubType::deleteData( +void MapWStringShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringShortPubSubType::getKey( +bool MapWStringShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -35311,35 +32940,27 @@ bool MapWStringShortPubSubType::getKey( const MapWStringShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -35352,49 +32973,42 @@ void MapWStringShortPubSubType::register_type_object_representation() MapWStringUShortPubSubType::MapWStringUShortPubSubType() { - setName("MapWStringUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringUShort::getMaxCdrSerializedSize()); -#else - MapWStringUShort_max_cdr_typesize; -#endif + set_name("MapWStringUShort"); + uint32_t type_size = MapWStringUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringUShort_max_key_cdr_typesize > 16 ? MapWStringUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringUShort_max_key_cdr_typesize > 16 ? MapWStringUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringUShortPubSubType::~MapWStringUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -35409,16 +33023,12 @@ bool MapWStringUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -35427,18 +33037,14 @@ bool MapWStringUShortPubSubType::deserialize( MapWStringUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -35451,336 +33057,138 @@ bool MapWStringUShortPubSubType::deserialize( return true; } -std::function MapWStringUShortPubSubType::getSerializedSizeProvider( +uint32_t MapWStringUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapWStringUShortPubSubType::createData() -{ - return reinterpret_cast(new MapWStringUShort()); -} - -void MapWStringUShortPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapWStringUShortPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapWStringUShort* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapWStringUShort_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapWStringUShort_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapWStringUShortPubSubType::register_type_object_representation() -{ - register_MapWStringUShort_type_identifier(type_identifiers_); } -MapWStringLongPubSubType::MapWStringLongPubSubType() +void* MapWStringUShortPubSubType::create_data() { - setName("MapWStringLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringLong::getMaxCdrSerializedSize()); -#else - MapWStringLong_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringLong_max_key_cdr_typesize > 16 ? MapWStringLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapWStringUShort()); } -MapWStringLongPubSubType::~MapWStringLongPubSubType() +void MapWStringUShortPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapWStringLongPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapWStringUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapWStringLong* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapWStringLongPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapWStringLong* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapWStringUShort data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapWStringLongPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapWStringLongPubSubType::createData() -{ - return reinterpret_cast(new MapWStringLong()); -} - -void MapWStringLongPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapWStringLongPubSubType::getKey( +bool MapWStringUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapWStringLong* p_type = static_cast(data); + const MapWStringUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapWStringLong_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapWStringUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapWStringLong_max_key_cdr_typesize > 16) + if (force_md5 || MapWStringUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapWStringLongPubSubType::register_type_object_representation() +void MapWStringUShortPubSubType::register_type_object_representation() { - register_MapWStringLong_type_identifier(type_identifiers_); + register_MapWStringUShort_type_identifier(type_identifiers_); } -MapWStringULongPubSubType::MapWStringULongPubSubType() +MapWStringLongPubSubType::MapWStringLongPubSubType() { - setName("MapWStringULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringULong::getMaxCdrSerializedSize()); -#else - MapWStringULong_max_cdr_typesize; -#endif + set_name("MapWStringLong"); + uint32_t type_size = MapWStringLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringULong_max_key_cdr_typesize > 16 ? MapWStringULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringLong_max_key_cdr_typesize > 16 ? MapWStringLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapWStringULongPubSubType::~MapWStringULongPubSubType() +MapWStringLongPubSubType::~MapWStringLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapWStringULongPubSubType::serialize( +bool MapWStringLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapWStringULong* p_type = static_cast(data); + const MapWStringLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -35795,16 +33203,192 @@ bool MapWStringULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapWStringLongPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapWStringLong* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapWStringLongPubSubType::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* MapWStringLongPubSubType::create_data() +{ + return reinterpret_cast(new MapWStringLong()); +} + +void MapWStringLongPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapWStringLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringLongPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapWStringLong* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapWStringLong_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapWStringLong_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 MapWStringLongPubSubType::register_type_object_representation() +{ + register_MapWStringLong_type_identifier(type_identifiers_); +} + +MapWStringULongPubSubType::MapWStringULongPubSubType() +{ + set_name("MapWStringULong"); + uint32_t type_size = MapWStringULong_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 = MapWStringULong_max_key_cdr_typesize > 16 ? MapWStringULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapWStringULongPubSubType::~MapWStringULongPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapWStringULongPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapWStringULong* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -35813,18 +33397,14 @@ bool MapWStringULongPubSubType::deserialize( MapWStringULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -35837,52 +33417,62 @@ bool MapWStringULongPubSubType::deserialize( return true; } -std::function MapWStringULongPubSubType::getSerializedSizeProvider( +uint32_t MapWStringULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringULongPubSubType::createData() +void* MapWStringULongPubSubType::create_data() { return reinterpret_cast(new MapWStringULong()); } -void MapWStringULongPubSubType::deleteData( +void MapWStringULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringULongPubSubType::getKey( +bool MapWStringULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -35890,35 +33480,27 @@ bool MapWStringULongPubSubType::getKey( const MapWStringULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -35931,49 +33513,42 @@ void MapWStringULongPubSubType::register_type_object_representation() MapWStringLongLongPubSubType::MapWStringLongLongPubSubType() { - setName("MapWStringLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringLongLong::getMaxCdrSerializedSize()); -#else - MapWStringLongLong_max_cdr_typesize; -#endif + set_name("MapWStringLongLong"); + uint32_t type_size = MapWStringLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringLongLong_max_key_cdr_typesize > 16 ? MapWStringLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringLongLong_max_key_cdr_typesize > 16 ? MapWStringLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringLongLongPubSubType::~MapWStringLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -35988,16 +33563,12 @@ bool MapWStringLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -36006,18 +33577,14 @@ bool MapWStringLongLongPubSubType::deserialize( MapWStringLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -36030,52 +33597,62 @@ bool MapWStringLongLongPubSubType::deserialize( return true; } -std::function MapWStringLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapWStringLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringLongLongPubSubType::createData() +void* MapWStringLongLongPubSubType::create_data() { return reinterpret_cast(new MapWStringLongLong()); } -void MapWStringLongLongPubSubType::deleteData( +void MapWStringLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringLongLongPubSubType::getKey( +bool MapWStringLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -36083,35 +33660,27 @@ bool MapWStringLongLongPubSubType::getKey( const MapWStringLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -36124,49 +33693,42 @@ void MapWStringLongLongPubSubType::register_type_object_representation() MapWStringULongLongPubSubType::MapWStringULongLongPubSubType() { - setName("MapWStringULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringULongLong::getMaxCdrSerializedSize()); -#else - MapWStringULongLong_max_cdr_typesize; -#endif + set_name("MapWStringULongLong"); + uint32_t type_size = MapWStringULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringULongLong_max_key_cdr_typesize > 16 ? MapWStringULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringULongLong_max_key_cdr_typesize > 16 ? MapWStringULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringULongLongPubSubType::~MapWStringULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -36181,16 +33743,12 @@ bool MapWStringULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -36199,18 +33757,14 @@ bool MapWStringULongLongPubSubType::deserialize( MapWStringULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -36223,52 +33777,62 @@ bool MapWStringULongLongPubSubType::deserialize( return true; } -std::function MapWStringULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapWStringULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringULongLongPubSubType::createData() +void* MapWStringULongLongPubSubType::create_data() { return reinterpret_cast(new MapWStringULongLong()); } -void MapWStringULongLongPubSubType::deleteData( +void MapWStringULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringULongLongPubSubType::getKey( +bool MapWStringULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -36276,35 +33840,27 @@ bool MapWStringULongLongPubSubType::getKey( const MapWStringULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -36317,49 +33873,42 @@ void MapWStringULongLongPubSubType::register_type_object_representation() MapWStringFloatPubSubType::MapWStringFloatPubSubType() { - setName("MapWStringFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringFloat::getMaxCdrSerializedSize()); -#else - MapWStringFloat_max_cdr_typesize; -#endif + set_name("MapWStringFloat"); + uint32_t type_size = MapWStringFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringFloat_max_key_cdr_typesize > 16 ? MapWStringFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringFloat_max_key_cdr_typesize > 16 ? MapWStringFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringFloatPubSubType::~MapWStringFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -36374,16 +33923,12 @@ bool MapWStringFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -36392,18 +33937,14 @@ bool MapWStringFloatPubSubType::deserialize( MapWStringFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -36416,52 +33957,62 @@ bool MapWStringFloatPubSubType::deserialize( return true; } -std::function MapWStringFloatPubSubType::getSerializedSizeProvider( +uint32_t MapWStringFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringFloatPubSubType::createData() +void* MapWStringFloatPubSubType::create_data() { return reinterpret_cast(new MapWStringFloat()); } -void MapWStringFloatPubSubType::deleteData( +void MapWStringFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringFloatPubSubType::getKey( +bool MapWStringFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -36469,35 +34020,27 @@ bool MapWStringFloatPubSubType::getKey( const MapWStringFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -36510,49 +34053,42 @@ void MapWStringFloatPubSubType::register_type_object_representation() MapWStringDoublePubSubType::MapWStringDoublePubSubType() { - setName("MapWStringDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringDouble::getMaxCdrSerializedSize()); -#else - MapWStringDouble_max_cdr_typesize; -#endif + set_name("MapWStringDouble"); + uint32_t type_size = MapWStringDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringDouble_max_key_cdr_typesize > 16 ? MapWStringDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringDouble_max_key_cdr_typesize > 16 ? MapWStringDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringDoublePubSubType::~MapWStringDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -36567,16 +34103,12 @@ bool MapWStringDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -36585,18 +34117,14 @@ bool MapWStringDoublePubSubType::deserialize( MapWStringDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -36609,52 +34137,62 @@ bool MapWStringDoublePubSubType::deserialize( return true; } -std::function MapWStringDoublePubSubType::getSerializedSizeProvider( +uint32_t MapWStringDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringDoublePubSubType::createData() +void* MapWStringDoublePubSubType::create_data() { return reinterpret_cast(new MapWStringDouble()); } -void MapWStringDoublePubSubType::deleteData( +void MapWStringDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringDoublePubSubType::getKey( +bool MapWStringDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -36662,35 +34200,27 @@ bool MapWStringDoublePubSubType::getKey( const MapWStringDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -36703,49 +34233,42 @@ void MapWStringDoublePubSubType::register_type_object_representation() MapWStringLongDoublePubSubType::MapWStringLongDoublePubSubType() { - setName("MapWStringLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringLongDouble::getMaxCdrSerializedSize()); -#else - MapWStringLongDouble_max_cdr_typesize; -#endif + set_name("MapWStringLongDouble"); + uint32_t type_size = MapWStringLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringLongDouble_max_key_cdr_typesize > 16 ? MapWStringLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringLongDouble_max_key_cdr_typesize > 16 ? MapWStringLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringLongDoublePubSubType::~MapWStringLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -36760,16 +34283,12 @@ bool MapWStringLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -36778,18 +34297,14 @@ bool MapWStringLongDoublePubSubType::deserialize( MapWStringLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -36802,52 +34317,62 @@ bool MapWStringLongDoublePubSubType::deserialize( return true; } -std::function MapWStringLongDoublePubSubType::getSerializedSizeProvider( +uint32_t MapWStringLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringLongDoublePubSubType::createData() +void* MapWStringLongDoublePubSubType::create_data() { return reinterpret_cast(new MapWStringLongDouble()); } -void MapWStringLongDoublePubSubType::deleteData( +void MapWStringLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringLongDoublePubSubType::getKey( +bool MapWStringLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -36855,35 +34380,27 @@ bool MapWStringLongDoublePubSubType::getKey( const MapWStringLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -36896,49 +34413,42 @@ void MapWStringLongDoublePubSubType::register_type_object_representation() MapWStringBooleanPubSubType::MapWStringBooleanPubSubType() { - setName("MapWStringBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringBoolean::getMaxCdrSerializedSize()); -#else - MapWStringBoolean_max_cdr_typesize; -#endif + set_name("MapWStringBoolean"); + uint32_t type_size = MapWStringBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringBoolean_max_key_cdr_typesize > 16 ? MapWStringBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringBoolean_max_key_cdr_typesize > 16 ? MapWStringBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringBooleanPubSubType::~MapWStringBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -36953,16 +34463,12 @@ bool MapWStringBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -36971,18 +34477,14 @@ bool MapWStringBooleanPubSubType::deserialize( MapWStringBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -36995,52 +34497,62 @@ bool MapWStringBooleanPubSubType::deserialize( return true; } -std::function MapWStringBooleanPubSubType::getSerializedSizeProvider( +uint32_t MapWStringBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringBooleanPubSubType::createData() +void* MapWStringBooleanPubSubType::create_data() { return reinterpret_cast(new MapWStringBoolean()); } -void MapWStringBooleanPubSubType::deleteData( +void MapWStringBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringBooleanPubSubType::getKey( +bool MapWStringBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -37048,35 +34560,27 @@ bool MapWStringBooleanPubSubType::getKey( const MapWStringBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -37089,49 +34593,42 @@ void MapWStringBooleanPubSubType::register_type_object_representation() MapWStringOctetPubSubType::MapWStringOctetPubSubType() { - setName("MapWStringOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringOctet::getMaxCdrSerializedSize()); -#else - MapWStringOctet_max_cdr_typesize; -#endif + set_name("MapWStringOctet"); + uint32_t type_size = MapWStringOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringOctet_max_key_cdr_typesize > 16 ? MapWStringOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringOctet_max_key_cdr_typesize > 16 ? MapWStringOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringOctetPubSubType::~MapWStringOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -37146,16 +34643,12 @@ bool MapWStringOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -37164,18 +34657,14 @@ bool MapWStringOctetPubSubType::deserialize( MapWStringOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -37188,52 +34677,62 @@ bool MapWStringOctetPubSubType::deserialize( return true; } -std::function MapWStringOctetPubSubType::getSerializedSizeProvider( +uint32_t MapWStringOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringOctetPubSubType::createData() +void* MapWStringOctetPubSubType::create_data() { return reinterpret_cast(new MapWStringOctet()); } -void MapWStringOctetPubSubType::deleteData( +void MapWStringOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringOctetPubSubType::getKey( +bool MapWStringOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -37241,35 +34740,27 @@ bool MapWStringOctetPubSubType::getKey( const MapWStringOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -37282,49 +34773,42 @@ void MapWStringOctetPubSubType::register_type_object_representation() MapWStringCharPubSubType::MapWStringCharPubSubType() { - setName("MapWStringChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringChar::getMaxCdrSerializedSize()); -#else - MapWStringChar_max_cdr_typesize; -#endif + set_name("MapWStringChar"); + uint32_t type_size = MapWStringChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringChar_max_key_cdr_typesize > 16 ? MapWStringChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringChar_max_key_cdr_typesize > 16 ? MapWStringChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringCharPubSubType::~MapWStringCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -37339,16 +34823,12 @@ bool MapWStringCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -37357,18 +34837,14 @@ bool MapWStringCharPubSubType::deserialize( MapWStringChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -37381,52 +34857,62 @@ bool MapWStringCharPubSubType::deserialize( return true; } -std::function MapWStringCharPubSubType::getSerializedSizeProvider( +uint32_t MapWStringCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringCharPubSubType::createData() +void* MapWStringCharPubSubType::create_data() { return reinterpret_cast(new MapWStringChar()); } -void MapWStringCharPubSubType::deleteData( +void MapWStringCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringCharPubSubType::getKey( +bool MapWStringCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -37434,35 +34920,27 @@ bool MapWStringCharPubSubType::getKey( const MapWStringChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -37475,49 +34953,42 @@ void MapWStringCharPubSubType::register_type_object_representation() MapWStringWCharPubSubType::MapWStringWCharPubSubType() { - setName("MapWStringWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringWChar::getMaxCdrSerializedSize()); -#else - MapWStringWChar_max_cdr_typesize; -#endif + set_name("MapWStringWChar"); + uint32_t type_size = MapWStringWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringWChar_max_key_cdr_typesize > 16 ? MapWStringWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringWChar_max_key_cdr_typesize > 16 ? MapWStringWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringWCharPubSubType::~MapWStringWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -37532,16 +35003,12 @@ bool MapWStringWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -37550,18 +35017,14 @@ bool MapWStringWCharPubSubType::deserialize( MapWStringWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -37574,52 +35037,62 @@ bool MapWStringWCharPubSubType::deserialize( return true; } -std::function MapWStringWCharPubSubType::getSerializedSizeProvider( +uint32_t MapWStringWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringWCharPubSubType::createData() +void* MapWStringWCharPubSubType::create_data() { return reinterpret_cast(new MapWStringWChar()); } -void MapWStringWCharPubSubType::deleteData( +void MapWStringWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringWCharPubSubType::getKey( +bool MapWStringWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -37627,35 +35100,27 @@ bool MapWStringWCharPubSubType::getKey( const MapWStringWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -37668,49 +35133,42 @@ void MapWStringWCharPubSubType::register_type_object_representation() MapWStringStringPubSubType::MapWStringStringPubSubType() { - setName("MapWStringString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringString::getMaxCdrSerializedSize()); -#else - MapWStringString_max_cdr_typesize; -#endif + set_name("MapWStringString"); + uint32_t type_size = MapWStringString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringString_max_key_cdr_typesize > 16 ? MapWStringString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringString_max_key_cdr_typesize > 16 ? MapWStringString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringStringPubSubType::~MapWStringStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -37725,16 +35183,12 @@ bool MapWStringStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -37743,18 +35197,14 @@ bool MapWStringStringPubSubType::deserialize( MapWStringString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -37767,52 +35217,62 @@ bool MapWStringStringPubSubType::deserialize( return true; } -std::function MapWStringStringPubSubType::getSerializedSizeProvider( +uint32_t MapWStringStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringStringPubSubType::createData() +void* MapWStringStringPubSubType::create_data() { return reinterpret_cast(new MapWStringString()); } -void MapWStringStringPubSubType::deleteData( +void MapWStringStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringStringPubSubType::getKey( +bool MapWStringStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -37820,35 +35280,27 @@ bool MapWStringStringPubSubType::getKey( const MapWStringString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -37861,49 +35313,42 @@ void MapWStringStringPubSubType::register_type_object_representation() MapWStringWStringPubSubType::MapWStringWStringPubSubType() { - setName("MapWStringWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringWString::getMaxCdrSerializedSize()); -#else - MapWStringWString_max_cdr_typesize; -#endif + set_name("MapWStringWString"); + uint32_t type_size = MapWStringWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringWString_max_key_cdr_typesize > 16 ? MapWStringWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringWString_max_key_cdr_typesize > 16 ? MapWStringWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringWStringPubSubType::~MapWStringWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -37918,16 +35363,12 @@ bool MapWStringWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -37936,18 +35377,14 @@ bool MapWStringWStringPubSubType::deserialize( MapWStringWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -37960,52 +35397,62 @@ bool MapWStringWStringPubSubType::deserialize( return true; } -std::function MapWStringWStringPubSubType::getSerializedSizeProvider( +uint32_t MapWStringWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringWStringPubSubType::createData() +void* MapWStringWStringPubSubType::create_data() { return reinterpret_cast(new MapWStringWString()); } -void MapWStringWStringPubSubType::deleteData( +void MapWStringWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringWStringPubSubType::getKey( +bool MapWStringWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -38013,35 +35460,27 @@ bool MapWStringWStringPubSubType::getKey( const MapWStringWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -38054,49 +35493,42 @@ void MapWStringWStringPubSubType::register_type_object_representation() MapWStringInnerAliasBoundedStringHelperPubSubType::MapWStringInnerAliasBoundedStringHelperPubSubType() { - setName("MapWStringInnerAliasBoundedStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerAliasBoundedStringHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerAliasBoundedStringHelper_max_cdr_typesize; -#endif + set_name("MapWStringInnerAliasBoundedStringHelper"); + uint32_t type_size = MapWStringInnerAliasBoundedStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringInnerAliasBoundedStringHelperPubSubType::~MapWStringInnerAliasBoundedStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringInnerAliasBoundedStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -38111,16 +35543,12 @@ bool MapWStringInnerAliasBoundedStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringInnerAliasBoundedStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -38129,18 +35557,14 @@ bool MapWStringInnerAliasBoundedStringHelperPubSubType::deserialize( MapWStringInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -38153,52 +35577,62 @@ bool MapWStringInnerAliasBoundedStringHelperPubSubType::deserialize( return true; } -std::function MapWStringInnerAliasBoundedStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapWStringInnerAliasBoundedStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringInnerAliasBoundedStringHelperPubSubType::createData() +void* MapWStringInnerAliasBoundedStringHelperPubSubType::create_data() { return reinterpret_cast(new MapWStringInnerAliasBoundedStringHelper()); } -void MapWStringInnerAliasBoundedStringHelperPubSubType::deleteData( +void MapWStringInnerAliasBoundedStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringInnerAliasBoundedStringHelperPubSubType::getKey( +bool MapWStringInnerAliasBoundedStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringInnerAliasBoundedStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringInnerAliasBoundedStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -38206,35 +35640,27 @@ bool MapWStringInnerAliasBoundedStringHelperPubSubType::getKey( const MapWStringInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringInnerAliasBoundedStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -38247,49 +35673,42 @@ void MapWStringInnerAliasBoundedStringHelperPubSubType::register_type_object_rep MapWStringInnerAliasBoundedWStringHelperPubSubType::MapWStringInnerAliasBoundedWStringHelperPubSubType() { - setName("MapWStringInnerAliasBoundedWStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerAliasBoundedWStringHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerAliasBoundedWStringHelper_max_cdr_typesize; -#endif + set_name("MapWStringInnerAliasBoundedWStringHelper"); + uint32_t type_size = MapWStringInnerAliasBoundedWStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringInnerAliasBoundedWStringHelperPubSubType::~MapWStringInnerAliasBoundedWStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringInnerAliasBoundedWStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -38304,16 +35723,12 @@ bool MapWStringInnerAliasBoundedWStringHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringInnerAliasBoundedWStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -38322,18 +35737,14 @@ bool MapWStringInnerAliasBoundedWStringHelperPubSubType::deserialize( MapWStringInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -38346,52 +35757,62 @@ bool MapWStringInnerAliasBoundedWStringHelperPubSubType::deserialize( return true; } -std::function MapWStringInnerAliasBoundedWStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapWStringInnerAliasBoundedWStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringInnerAliasBoundedWStringHelperPubSubType::createData() +void* MapWStringInnerAliasBoundedWStringHelperPubSubType::create_data() { return reinterpret_cast(new MapWStringInnerAliasBoundedWStringHelper()); } -void MapWStringInnerAliasBoundedWStringHelperPubSubType::deleteData( +void MapWStringInnerAliasBoundedWStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringInnerAliasBoundedWStringHelperPubSubType::getKey( +bool MapWStringInnerAliasBoundedWStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringInnerAliasBoundedWStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringInnerAliasBoundedWStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -38399,35 +35820,27 @@ bool MapWStringInnerAliasBoundedWStringHelperPubSubType::getKey( const MapWStringInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -38440,49 +35853,42 @@ void MapWStringInnerAliasBoundedWStringHelperPubSubType::register_type_object_re MapWStringInnerEnumHelperPubSubType::MapWStringInnerEnumHelperPubSubType() { - setName("MapWStringInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerEnumHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerEnumHelper_max_cdr_typesize; -#endif + set_name("MapWStringInnerEnumHelper"); + uint32_t type_size = MapWStringInnerEnumHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerEnumHelper_max_key_cdr_typesize > 16 ? MapWStringInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringInnerEnumHelper_max_key_cdr_typesize > 16 ? MapWStringInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringInnerEnumHelperPubSubType::~MapWStringInnerEnumHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringInnerEnumHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -38497,16 +35903,12 @@ bool MapWStringInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -38515,18 +35917,14 @@ bool MapWStringInnerEnumHelperPubSubType::deserialize( MapWStringInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -38539,336 +35937,138 @@ bool MapWStringInnerEnumHelperPubSubType::deserialize( return true; } -std::function MapWStringInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t MapWStringInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapWStringInnerEnumHelperPubSubType::createData() -{ - return reinterpret_cast(new MapWStringInnerEnumHelper()); -} - -void MapWStringInnerEnumHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapWStringInnerEnumHelperPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapWStringInnerEnumHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapWStringInnerEnumHelper_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapWStringInnerEnumHelper_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapWStringInnerEnumHelperPubSubType::register_type_object_representation() -{ - register_MapWStringInnerEnumHelper_type_identifier(type_identifiers_); } -MapWStringInnerBitMaskHelperPubSubType::MapWStringInnerBitMaskHelperPubSubType() +void* MapWStringInnerEnumHelperPubSubType::create_data() { - setName("MapWStringInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerBitMaskHelper_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapWStringInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapWStringInnerEnumHelper()); } -MapWStringInnerBitMaskHelperPubSubType::~MapWStringInnerBitMaskHelperPubSubType() +void MapWStringInnerEnumHelperPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapWStringInnerBitMaskHelperPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapWStringInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapWStringInnerBitMaskHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapWStringInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapWStringInnerBitMaskHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapWStringInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapWStringInnerBitMaskHelperPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapWStringInnerBitMaskHelperPubSubType::createData() -{ - return reinterpret_cast(new MapWStringInnerBitMaskHelper()); -} - -void MapWStringInnerBitMaskHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapWStringInnerBitMaskHelperPubSubType::getKey( +bool MapWStringInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapWStringInnerBitMaskHelper* p_type = static_cast(data); + const MapWStringInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapWStringInnerBitMaskHelper_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapWStringInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapWStringInnerBitMaskHelper_max_key_cdr_typesize > 16) + if (force_md5 || MapWStringInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapWStringInnerBitMaskHelperPubSubType::register_type_object_representation() +void MapWStringInnerEnumHelperPubSubType::register_type_object_representation() { - register_MapWStringInnerBitMaskHelper_type_identifier(type_identifiers_); + register_MapWStringInnerEnumHelper_type_identifier(type_identifiers_); } -MapWStringInnerAliasHelperPubSubType::MapWStringInnerAliasHelperPubSubType() +MapWStringInnerBitMaskHelperPubSubType::MapWStringInnerBitMaskHelperPubSubType() { - setName("MapWStringInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerAliasHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerAliasHelper_max_cdr_typesize; -#endif + set_name("MapWStringInnerBitMaskHelper"); + uint32_t type_size = MapWStringInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerAliasHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapWStringInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapWStringInnerAliasHelperPubSubType::~MapWStringInnerAliasHelperPubSubType() +MapWStringInnerBitMaskHelperPubSubType::~MapWStringInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapWStringInnerAliasHelperPubSubType::serialize( +bool MapWStringInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapWStringInnerAliasHelper* p_type = static_cast(data); + const MapWStringInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -38883,16 +36083,192 @@ bool MapWStringInnerAliasHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapWStringInnerBitMaskHelperPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapWStringInnerBitMaskHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapWStringInnerBitMaskHelperPubSubType::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* MapWStringInnerBitMaskHelperPubSubType::create_data() +{ + return reinterpret_cast(new MapWStringInnerBitMaskHelper()); +} + +void MapWStringInnerBitMaskHelperPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapWStringInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringInnerBitMaskHelperPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapWStringInnerBitMaskHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapWStringInnerBitMaskHelper_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapWStringInnerBitMaskHelper_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 MapWStringInnerBitMaskHelperPubSubType::register_type_object_representation() +{ + register_MapWStringInnerBitMaskHelper_type_identifier(type_identifiers_); +} + +MapWStringInnerAliasHelperPubSubType::MapWStringInnerAliasHelperPubSubType() +{ + set_name("MapWStringInnerAliasHelper"); + uint32_t type_size = MapWStringInnerAliasHelper_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 = MapWStringInnerAliasHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapWStringInnerAliasHelperPubSubType::~MapWStringInnerAliasHelperPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapWStringInnerAliasHelperPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapWStringInnerAliasHelper* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -38901,18 +36277,14 @@ bool MapWStringInnerAliasHelperPubSubType::deserialize( MapWStringInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -38925,52 +36297,62 @@ bool MapWStringInnerAliasHelperPubSubType::deserialize( return true; } -std::function MapWStringInnerAliasHelperPubSubType::getSerializedSizeProvider( +uint32_t MapWStringInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringInnerAliasHelperPubSubType::createData() +void* MapWStringInnerAliasHelperPubSubType::create_data() { return reinterpret_cast(new MapWStringInnerAliasHelper()); } -void MapWStringInnerAliasHelperPubSubType::deleteData( +void MapWStringInnerAliasHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringInnerAliasHelperPubSubType::getKey( +bool MapWStringInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -38978,35 +36360,27 @@ bool MapWStringInnerAliasHelperPubSubType::getKey( const MapWStringInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -39019,49 +36393,42 @@ void MapWStringInnerAliasHelperPubSubType::register_type_object_representation() MapWStringInnerAliasArrayHelperPubSubType::MapWStringInnerAliasArrayHelperPubSubType() { - setName("MapWStringInnerAliasArrayHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerAliasArrayHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerAliasArrayHelper_max_cdr_typesize; -#endif + set_name("MapWStringInnerAliasArrayHelper"); + uint32_t type_size = MapWStringInnerAliasArrayHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasArrayHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasArrayHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringInnerAliasArrayHelperPubSubType::~MapWStringInnerAliasArrayHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringInnerAliasArrayHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -39076,16 +36443,12 @@ bool MapWStringInnerAliasArrayHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringInnerAliasArrayHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -39094,18 +36457,14 @@ bool MapWStringInnerAliasArrayHelperPubSubType::deserialize( MapWStringInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -39118,52 +36477,62 @@ bool MapWStringInnerAliasArrayHelperPubSubType::deserialize( return true; } -std::function MapWStringInnerAliasArrayHelperPubSubType::getSerializedSizeProvider( +uint32_t MapWStringInnerAliasArrayHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringInnerAliasArrayHelperPubSubType::createData() +void* MapWStringInnerAliasArrayHelperPubSubType::create_data() { return reinterpret_cast(new MapWStringInnerAliasArrayHelper()); } -void MapWStringInnerAliasArrayHelperPubSubType::deleteData( +void MapWStringInnerAliasArrayHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringInnerAliasArrayHelperPubSubType::getKey( +bool MapWStringInnerAliasArrayHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringInnerAliasArrayHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringInnerAliasArrayHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -39171,35 +36540,27 @@ bool MapWStringInnerAliasArrayHelperPubSubType::getKey( const MapWStringInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringInnerAliasArrayHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringInnerAliasArrayHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -39212,49 +36573,42 @@ void MapWStringInnerAliasArrayHelperPubSubType::register_type_object_representat MapWStringInnerAliasSequenceHelperPubSubType::MapWStringInnerAliasSequenceHelperPubSubType() { - setName("MapWStringInnerAliasSequenceHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerAliasSequenceHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerAliasSequenceHelper_max_cdr_typesize; -#endif + set_name("MapWStringInnerAliasSequenceHelper"); + uint32_t type_size = MapWStringInnerAliasSequenceHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasSequenceHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasSequenceHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringInnerAliasSequenceHelperPubSubType::~MapWStringInnerAliasSequenceHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringInnerAliasSequenceHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -39269,16 +36623,12 @@ bool MapWStringInnerAliasSequenceHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringInnerAliasSequenceHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -39287,18 +36637,14 @@ bool MapWStringInnerAliasSequenceHelperPubSubType::deserialize( MapWStringInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -39311,52 +36657,62 @@ bool MapWStringInnerAliasSequenceHelperPubSubType::deserialize( return true; } -std::function MapWStringInnerAliasSequenceHelperPubSubType::getSerializedSizeProvider( +uint32_t MapWStringInnerAliasSequenceHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringInnerAliasSequenceHelperPubSubType::createData() +void* MapWStringInnerAliasSequenceHelperPubSubType::create_data() { return reinterpret_cast(new MapWStringInnerAliasSequenceHelper()); } -void MapWStringInnerAliasSequenceHelperPubSubType::deleteData( +void MapWStringInnerAliasSequenceHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringInnerAliasSequenceHelperPubSubType::getKey( +bool MapWStringInnerAliasSequenceHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringInnerAliasSequenceHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringInnerAliasSequenceHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -39364,35 +36720,27 @@ bool MapWStringInnerAliasSequenceHelperPubSubType::getKey( const MapWStringInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringInnerAliasSequenceHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringInnerAliasSequenceHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -39405,49 +36753,42 @@ void MapWStringInnerAliasSequenceHelperPubSubType::register_type_object_represen MapWStringInnerAliasMapHelperPubSubType::MapWStringInnerAliasMapHelperPubSubType() { - setName("MapWStringInnerAliasMapHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerAliasMapHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerAliasMapHelper_max_cdr_typesize; -#endif + set_name("MapWStringInnerAliasMapHelper"); + uint32_t type_size = MapWStringInnerAliasMapHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasMapHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapWStringInnerAliasMapHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringInnerAliasMapHelperPubSubType::~MapWStringInnerAliasMapHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringInnerAliasMapHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -39462,16 +36803,12 @@ bool MapWStringInnerAliasMapHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringInnerAliasMapHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -39480,18 +36817,14 @@ bool MapWStringInnerAliasMapHelperPubSubType::deserialize( MapWStringInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -39504,52 +36837,62 @@ bool MapWStringInnerAliasMapHelperPubSubType::deserialize( return true; } -std::function MapWStringInnerAliasMapHelperPubSubType::getSerializedSizeProvider( +uint32_t MapWStringInnerAliasMapHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringInnerAliasMapHelperPubSubType::createData() +void* MapWStringInnerAliasMapHelperPubSubType::create_data() { return reinterpret_cast(new MapWStringInnerAliasMapHelper()); } -void MapWStringInnerAliasMapHelperPubSubType::deleteData( +void MapWStringInnerAliasMapHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringInnerAliasMapHelperPubSubType::getKey( +bool MapWStringInnerAliasMapHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringInnerAliasMapHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringInnerAliasMapHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -39557,35 +36900,27 @@ bool MapWStringInnerAliasMapHelperPubSubType::getKey( const MapWStringInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringInnerAliasMapHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringInnerAliasMapHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -39598,49 +36933,42 @@ void MapWStringInnerAliasMapHelperPubSubType::register_type_object_representatio MapWStringInnerUnionHelperPubSubType::MapWStringInnerUnionHelperPubSubType() { - setName("MapWStringInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerUnionHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerUnionHelper_max_cdr_typesize; -#endif + set_name("MapWStringInnerUnionHelper"); + uint32_t type_size = MapWStringInnerUnionHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerUnionHelper_max_key_cdr_typesize > 16 ? MapWStringInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringInnerUnionHelper_max_key_cdr_typesize > 16 ? MapWStringInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringInnerUnionHelperPubSubType::~MapWStringInnerUnionHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringInnerUnionHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -39655,16 +36983,12 @@ bool MapWStringInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -39673,18 +36997,14 @@ bool MapWStringInnerUnionHelperPubSubType::deserialize( MapWStringInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -39697,52 +37017,62 @@ bool MapWStringInnerUnionHelperPubSubType::deserialize( return true; } -std::function MapWStringInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t MapWStringInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringInnerUnionHelperPubSubType::createData() +void* MapWStringInnerUnionHelperPubSubType::create_data() { return reinterpret_cast(new MapWStringInnerUnionHelper()); } -void MapWStringInnerUnionHelperPubSubType::deleteData( +void MapWStringInnerUnionHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringInnerUnionHelperPubSubType::getKey( +bool MapWStringInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -39750,35 +37080,27 @@ bool MapWStringInnerUnionHelperPubSubType::getKey( const MapWStringInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -39791,49 +37113,42 @@ void MapWStringInnerUnionHelperPubSubType::register_type_object_representation() MapWStringInnerStructureHelperPubSubType::MapWStringInnerStructureHelperPubSubType() { - setName("MapWStringInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerStructureHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerStructureHelper_max_cdr_typesize; -#endif + set_name("MapWStringInnerStructureHelper"); + uint32_t type_size = MapWStringInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerStructureHelper_max_key_cdr_typesize > 16 ? MapWStringInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringInnerStructureHelper_max_key_cdr_typesize > 16 ? MapWStringInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringInnerStructureHelperPubSubType::~MapWStringInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -39848,16 +37163,12 @@ bool MapWStringInnerStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -39866,18 +37177,14 @@ bool MapWStringInnerStructureHelperPubSubType::deserialize( MapWStringInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -39890,52 +37197,62 @@ bool MapWStringInnerStructureHelperPubSubType::deserialize( return true; } -std::function MapWStringInnerStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t MapWStringInnerStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringInnerStructureHelperPubSubType::createData() +void* MapWStringInnerStructureHelperPubSubType::create_data() { return reinterpret_cast(new MapWStringInnerStructureHelper()); } -void MapWStringInnerStructureHelperPubSubType::deleteData( +void MapWStringInnerStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringInnerStructureHelperPubSubType::getKey( +bool MapWStringInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringInnerStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -39943,35 +37260,27 @@ bool MapWStringInnerStructureHelperPubSubType::getKey( const MapWStringInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringInnerStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringInnerStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -39984,49 +37293,42 @@ void MapWStringInnerStructureHelperPubSubType::register_type_object_representati MapWStringInnerBitsetHelperPubSubType::MapWStringInnerBitsetHelperPubSubType() { - setName("MapWStringInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapWStringInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - MapWStringInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("MapWStringInnerBitsetHelper"); + uint32_t type_size = MapWStringInnerBitsetHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapWStringInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapWStringInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapWStringInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapWStringInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapWStringInnerBitsetHelperPubSubType::~MapWStringInnerBitsetHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapWStringInnerBitsetHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapWStringInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -40041,16 +37343,12 @@ bool MapWStringInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapWStringInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -40059,18 +37357,14 @@ bool MapWStringInnerBitsetHelperPubSubType::deserialize( MapWStringInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -40083,52 +37377,62 @@ bool MapWStringInnerBitsetHelperPubSubType::deserialize( return true; } -std::function MapWStringInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t MapWStringInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapWStringInnerBitsetHelperPubSubType::createData() +void* MapWStringInnerBitsetHelperPubSubType::create_data() { return reinterpret_cast(new MapWStringInnerBitsetHelper()); } -void MapWStringInnerBitsetHelperPubSubType::deleteData( +void MapWStringInnerBitsetHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapWStringInnerBitsetHelperPubSubType::getKey( +bool MapWStringInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapWStringInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapWStringInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -40136,35 +37440,27 @@ bool MapWStringInnerBitsetHelperPubSubType::getKey( const MapWStringInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapWStringInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapWStringInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -40177,49 +37473,42 @@ void MapWStringInnerBitsetHelperPubSubType::register_type_object_representation( MapInnerAliasBoundedStringHelperShortPubSubType::MapInnerAliasBoundedStringHelperShortPubSubType() { - setName("MapInnerAliasBoundedStringHelperShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperShort::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperShort_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperShort"); + uint32_t type_size = MapInnerAliasBoundedStringHelperShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperShort_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperShort_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperShortPubSubType::~MapInnerAliasBoundedStringHelperShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -40234,16 +37523,12 @@ bool MapInnerAliasBoundedStringHelperShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -40252,18 +37537,14 @@ bool MapInnerAliasBoundedStringHelperShortPubSubType::deserialize( MapInnerAliasBoundedStringHelperShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -40276,52 +37557,62 @@ bool MapInnerAliasBoundedStringHelperShortPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperShortPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperShortPubSubType::createData() +void* MapInnerAliasBoundedStringHelperShortPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperShort()); } -void MapInnerAliasBoundedStringHelperShortPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperShortPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -40329,35 +37620,27 @@ bool MapInnerAliasBoundedStringHelperShortPubSubType::getKey( const MapInnerAliasBoundedStringHelperShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -40370,49 +37653,42 @@ void MapInnerAliasBoundedStringHelperShortPubSubType::register_type_object_repre MapInnerAliasBoundedStringHelperUShortPubSubType::MapInnerAliasBoundedStringHelperUShortPubSubType() { - setName("MapInnerAliasBoundedStringHelperUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperUShort::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperUShort_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperUShort"); + uint32_t type_size = MapInnerAliasBoundedStringHelperUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperUShort_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperUShort_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperUShortPubSubType::~MapInnerAliasBoundedStringHelperUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -40427,16 +37703,12 @@ bool MapInnerAliasBoundedStringHelperUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -40445,18 +37717,14 @@ bool MapInnerAliasBoundedStringHelperUShortPubSubType::deserialize( MapInnerAliasBoundedStringHelperUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -40469,52 +37737,62 @@ bool MapInnerAliasBoundedStringHelperUShortPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperUShortPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperUShortPubSubType::createData() +void* MapInnerAliasBoundedStringHelperUShortPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperUShort()); } -void MapInnerAliasBoundedStringHelperUShortPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperUShortPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -40522,35 +37800,27 @@ bool MapInnerAliasBoundedStringHelperUShortPubSubType::getKey( const MapInnerAliasBoundedStringHelperUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -40563,49 +37833,42 @@ void MapInnerAliasBoundedStringHelperUShortPubSubType::register_type_object_repr MapInnerAliasBoundedStringHelperLongPubSubType::MapInnerAliasBoundedStringHelperLongPubSubType() { - setName("MapInnerAliasBoundedStringHelperLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperLong::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperLong_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperLong"); + uint32_t type_size = MapInnerAliasBoundedStringHelperLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperLongPubSubType::~MapInnerAliasBoundedStringHelperLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -40620,16 +37883,12 @@ bool MapInnerAliasBoundedStringHelperLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -40638,18 +37897,14 @@ bool MapInnerAliasBoundedStringHelperLongPubSubType::deserialize( MapInnerAliasBoundedStringHelperLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -40662,52 +37917,62 @@ bool MapInnerAliasBoundedStringHelperLongPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperLongPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperLongPubSubType::createData() +void* MapInnerAliasBoundedStringHelperLongPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperLong()); } -void MapInnerAliasBoundedStringHelperLongPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperLongPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -40715,35 +37980,27 @@ bool MapInnerAliasBoundedStringHelperLongPubSubType::getKey( const MapInnerAliasBoundedStringHelperLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -40756,49 +38013,42 @@ void MapInnerAliasBoundedStringHelperLongPubSubType::register_type_object_repres MapInnerAliasBoundedStringHelperULongPubSubType::MapInnerAliasBoundedStringHelperULongPubSubType() { - setName("MapInnerAliasBoundedStringHelperULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperULong::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperULong_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperULong"); + uint32_t type_size = MapInnerAliasBoundedStringHelperULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperULong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperULong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperULongPubSubType::~MapInnerAliasBoundedStringHelperULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -40813,16 +38063,12 @@ bool MapInnerAliasBoundedStringHelperULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -40831,18 +38077,14 @@ bool MapInnerAliasBoundedStringHelperULongPubSubType::deserialize( MapInnerAliasBoundedStringHelperULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -40855,52 +38097,62 @@ bool MapInnerAliasBoundedStringHelperULongPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperULongPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperULongPubSubType::createData() +void* MapInnerAliasBoundedStringHelperULongPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperULong()); } -void MapInnerAliasBoundedStringHelperULongPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperULongPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -40908,35 +38160,27 @@ bool MapInnerAliasBoundedStringHelperULongPubSubType::getKey( const MapInnerAliasBoundedStringHelperULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -40949,49 +38193,42 @@ void MapInnerAliasBoundedStringHelperULongPubSubType::register_type_object_repre MapInnerAliasBoundedStringHelperLongLongPubSubType::MapInnerAliasBoundedStringHelperLongLongPubSubType() { - setName("MapInnerAliasBoundedStringHelperLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperLongLong::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperLongLong_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperLongLong"); + uint32_t type_size = MapInnerAliasBoundedStringHelperLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperLongLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperLongLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperLongLongPubSubType::~MapInnerAliasBoundedStringHelperLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -41006,16 +38243,12 @@ bool MapInnerAliasBoundedStringHelperLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -41024,18 +38257,14 @@ bool MapInnerAliasBoundedStringHelperLongLongPubSubType::deserialize( MapInnerAliasBoundedStringHelperLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -41048,52 +38277,62 @@ bool MapInnerAliasBoundedStringHelperLongLongPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperLongLongPubSubType::createData() +void* MapInnerAliasBoundedStringHelperLongLongPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperLongLong()); } -void MapInnerAliasBoundedStringHelperLongLongPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperLongLongPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -41101,35 +38340,27 @@ bool MapInnerAliasBoundedStringHelperLongLongPubSubType::getKey( const MapInnerAliasBoundedStringHelperLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -41142,49 +38373,42 @@ void MapInnerAliasBoundedStringHelperLongLongPubSubType::register_type_object_re MapInnerAliasBoundedStringHelperULongLongPubSubType::MapInnerAliasBoundedStringHelperULongLongPubSubType() { - setName("MapInnerAliasBoundedStringHelperULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperULongLong::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperULongLong_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperULongLong"); + uint32_t type_size = MapInnerAliasBoundedStringHelperULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperULongLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperULongLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperULongLongPubSubType::~MapInnerAliasBoundedStringHelperULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -41199,16 +38423,12 @@ bool MapInnerAliasBoundedStringHelperULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -41217,18 +38437,14 @@ bool MapInnerAliasBoundedStringHelperULongLongPubSubType::deserialize( MapInnerAliasBoundedStringHelperULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -41241,52 +38457,62 @@ bool MapInnerAliasBoundedStringHelperULongLongPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperULongLongPubSubType::createData() +void* MapInnerAliasBoundedStringHelperULongLongPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperULongLong()); } -void MapInnerAliasBoundedStringHelperULongLongPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperULongLongPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -41294,35 +38520,27 @@ bool MapInnerAliasBoundedStringHelperULongLongPubSubType::getKey( const MapInnerAliasBoundedStringHelperULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -41335,49 +38553,42 @@ void MapInnerAliasBoundedStringHelperULongLongPubSubType::register_type_object_r MapInnerAliasBoundedStringHelperFloatPubSubType::MapInnerAliasBoundedStringHelperFloatPubSubType() { - setName("MapInnerAliasBoundedStringHelperFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperFloat::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperFloat_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperFloat"); + uint32_t type_size = MapInnerAliasBoundedStringHelperFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperFloat_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperFloat_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperFloatPubSubType::~MapInnerAliasBoundedStringHelperFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -41392,16 +38603,12 @@ bool MapInnerAliasBoundedStringHelperFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -41410,18 +38617,14 @@ bool MapInnerAliasBoundedStringHelperFloatPubSubType::deserialize( MapInnerAliasBoundedStringHelperFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -41434,52 +38637,62 @@ bool MapInnerAliasBoundedStringHelperFloatPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperFloatPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperFloatPubSubType::createData() +void* MapInnerAliasBoundedStringHelperFloatPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperFloat()); } -void MapInnerAliasBoundedStringHelperFloatPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperFloatPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -41487,35 +38700,27 @@ bool MapInnerAliasBoundedStringHelperFloatPubSubType::getKey( const MapInnerAliasBoundedStringHelperFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -41528,49 +38733,42 @@ void MapInnerAliasBoundedStringHelperFloatPubSubType::register_type_object_repre MapInnerAliasBoundedStringHelperDoublePubSubType::MapInnerAliasBoundedStringHelperDoublePubSubType() { - setName("MapInnerAliasBoundedStringHelperDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperDouble::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperDouble_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperDouble"); + uint32_t type_size = MapInnerAliasBoundedStringHelperDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperDouble_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperDouble_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperDoublePubSubType::~MapInnerAliasBoundedStringHelperDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -41585,16 +38783,12 @@ bool MapInnerAliasBoundedStringHelperDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -41603,18 +38797,14 @@ bool MapInnerAliasBoundedStringHelperDoublePubSubType::deserialize( MapInnerAliasBoundedStringHelperDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -41627,336 +38817,138 @@ bool MapInnerAliasBoundedStringHelperDoublePubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperDoublePubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapInnerAliasBoundedStringHelperDoublePubSubType::createData() -{ - return reinterpret_cast(new MapInnerAliasBoundedStringHelperDouble()); -} - -void MapInnerAliasBoundedStringHelperDoublePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapInnerAliasBoundedStringHelperDoublePubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapInnerAliasBoundedStringHelperDouble* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapInnerAliasBoundedStringHelperDouble_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapInnerAliasBoundedStringHelperDouble_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapInnerAliasBoundedStringHelperDoublePubSubType::register_type_object_representation() -{ - register_MapInnerAliasBoundedStringHelperDouble_type_identifier(type_identifiers_); } -MapInnerAliasBoundedStringHelperLongDoublePubSubType::MapInnerAliasBoundedStringHelperLongDoublePubSubType() +void* MapInnerAliasBoundedStringHelperDoublePubSubType::create_data() { - setName("MapInnerAliasBoundedStringHelperLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperLongDouble::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperLongDouble_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperLongDouble_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapInnerAliasBoundedStringHelperDouble()); } -MapInnerAliasBoundedStringHelperLongDoublePubSubType::~MapInnerAliasBoundedStringHelperLongDoublePubSubType() +void MapInnerAliasBoundedStringHelperDoublePubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperLongDoublePubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapInnerAliasBoundedStringHelperDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapInnerAliasBoundedStringHelperLongDouble* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapInnerAliasBoundedStringHelperLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapInnerAliasBoundedStringHelperLongDouble* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapInnerAliasBoundedStringHelperDouble data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapInnerAliasBoundedStringHelperLongDoublePubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapInnerAliasBoundedStringHelperLongDoublePubSubType::createData() -{ - return reinterpret_cast(new MapInnerAliasBoundedStringHelperLongDouble()); -} - -void MapInnerAliasBoundedStringHelperLongDoublePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapInnerAliasBoundedStringHelperLongDoublePubSubType::getKey( +bool MapInnerAliasBoundedStringHelperDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapInnerAliasBoundedStringHelperLongDouble* p_type = static_cast(data); + const MapInnerAliasBoundedStringHelperDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapInnerAliasBoundedStringHelperLongDouble_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapInnerAliasBoundedStringHelperDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapInnerAliasBoundedStringHelperLongDouble_max_key_cdr_typesize > 16) + if (force_md5 || MapInnerAliasBoundedStringHelperDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapInnerAliasBoundedStringHelperLongDoublePubSubType::register_type_object_representation() +void MapInnerAliasBoundedStringHelperDoublePubSubType::register_type_object_representation() { - register_MapInnerAliasBoundedStringHelperLongDouble_type_identifier(type_identifiers_); + register_MapInnerAliasBoundedStringHelperDouble_type_identifier(type_identifiers_); } -MapInnerAliasBoundedStringHelperBooleanPubSubType::MapInnerAliasBoundedStringHelperBooleanPubSubType() +MapInnerAliasBoundedStringHelperLongDoublePubSubType::MapInnerAliasBoundedStringHelperLongDoublePubSubType() { - setName("MapInnerAliasBoundedStringHelperBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperBoolean::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperBoolean_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperLongDouble"); + uint32_t type_size = MapInnerAliasBoundedStringHelperLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperBoolean_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperLongDouble_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapInnerAliasBoundedStringHelperBooleanPubSubType::~MapInnerAliasBoundedStringHelperBooleanPubSubType() +MapInnerAliasBoundedStringHelperLongDoublePubSubType::~MapInnerAliasBoundedStringHelperLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapInnerAliasBoundedStringHelperBooleanPubSubType::serialize( +bool MapInnerAliasBoundedStringHelperLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapInnerAliasBoundedStringHelperBoolean* p_type = static_cast(data); + const MapInnerAliasBoundedStringHelperLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -41971,16 +38963,192 @@ bool MapInnerAliasBoundedStringHelperBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapInnerAliasBoundedStringHelperLongDoublePubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapInnerAliasBoundedStringHelperLongDouble* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapInnerAliasBoundedStringHelperLongDoublePubSubType::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* MapInnerAliasBoundedStringHelperLongDoublePubSubType::create_data() +{ + return reinterpret_cast(new MapInnerAliasBoundedStringHelperLongDouble()); +} + +void MapInnerAliasBoundedStringHelperLongDoublePubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapInnerAliasBoundedStringHelperLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperLongDoublePubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapInnerAliasBoundedStringHelperLongDouble* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapInnerAliasBoundedStringHelperLongDouble_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapInnerAliasBoundedStringHelperLongDouble_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 MapInnerAliasBoundedStringHelperLongDoublePubSubType::register_type_object_representation() +{ + register_MapInnerAliasBoundedStringHelperLongDouble_type_identifier(type_identifiers_); +} + +MapInnerAliasBoundedStringHelperBooleanPubSubType::MapInnerAliasBoundedStringHelperBooleanPubSubType() +{ + set_name("MapInnerAliasBoundedStringHelperBoolean"); + uint32_t type_size = MapInnerAliasBoundedStringHelperBoolean_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 = MapInnerAliasBoundedStringHelperBoolean_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapInnerAliasBoundedStringHelperBooleanPubSubType::~MapInnerAliasBoundedStringHelperBooleanPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapInnerAliasBoundedStringHelperBooleanPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapInnerAliasBoundedStringHelperBoolean* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -41989,18 +39157,14 @@ bool MapInnerAliasBoundedStringHelperBooleanPubSubType::deserialize( MapInnerAliasBoundedStringHelperBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -42013,52 +39177,62 @@ bool MapInnerAliasBoundedStringHelperBooleanPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperBooleanPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperBooleanPubSubType::createData() +void* MapInnerAliasBoundedStringHelperBooleanPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperBoolean()); } -void MapInnerAliasBoundedStringHelperBooleanPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperBooleanPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -42066,35 +39240,27 @@ bool MapInnerAliasBoundedStringHelperBooleanPubSubType::getKey( const MapInnerAliasBoundedStringHelperBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -42107,49 +39273,42 @@ void MapInnerAliasBoundedStringHelperBooleanPubSubType::register_type_object_rep MapInnerAliasBoundedStringHelperOctetPubSubType::MapInnerAliasBoundedStringHelperOctetPubSubType() { - setName("MapInnerAliasBoundedStringHelperOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperOctet::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperOctet_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperOctet"); + uint32_t type_size = MapInnerAliasBoundedStringHelperOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperOctet_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperOctet_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperOctetPubSubType::~MapInnerAliasBoundedStringHelperOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -42164,16 +39323,12 @@ bool MapInnerAliasBoundedStringHelperOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -42182,18 +39337,14 @@ bool MapInnerAliasBoundedStringHelperOctetPubSubType::deserialize( MapInnerAliasBoundedStringHelperOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -42206,52 +39357,62 @@ bool MapInnerAliasBoundedStringHelperOctetPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperOctetPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperOctetPubSubType::createData() +void* MapInnerAliasBoundedStringHelperOctetPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperOctet()); } -void MapInnerAliasBoundedStringHelperOctetPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperOctetPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -42259,35 +39420,27 @@ bool MapInnerAliasBoundedStringHelperOctetPubSubType::getKey( const MapInnerAliasBoundedStringHelperOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -42300,49 +39453,42 @@ void MapInnerAliasBoundedStringHelperOctetPubSubType::register_type_object_repre MapInnerAliasBoundedStringHelperCharPubSubType::MapInnerAliasBoundedStringHelperCharPubSubType() { - setName("MapInnerAliasBoundedStringHelperChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperChar::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperChar_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperChar"); + uint32_t type_size = MapInnerAliasBoundedStringHelperChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperChar_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperChar_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperCharPubSubType::~MapInnerAliasBoundedStringHelperCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -42357,16 +39503,12 @@ bool MapInnerAliasBoundedStringHelperCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -42375,18 +39517,14 @@ bool MapInnerAliasBoundedStringHelperCharPubSubType::deserialize( MapInnerAliasBoundedStringHelperChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -42399,52 +39537,62 @@ bool MapInnerAliasBoundedStringHelperCharPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperCharPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperCharPubSubType::createData() +void* MapInnerAliasBoundedStringHelperCharPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperChar()); } -void MapInnerAliasBoundedStringHelperCharPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperCharPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -42452,35 +39600,27 @@ bool MapInnerAliasBoundedStringHelperCharPubSubType::getKey( const MapInnerAliasBoundedStringHelperChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -42493,49 +39633,42 @@ void MapInnerAliasBoundedStringHelperCharPubSubType::register_type_object_repres MapInnerAliasBoundedStringHelperWCharPubSubType::MapInnerAliasBoundedStringHelperWCharPubSubType() { - setName("MapInnerAliasBoundedStringHelperWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperWChar::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperWChar_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperWChar"); + uint32_t type_size = MapInnerAliasBoundedStringHelperWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperWChar_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperWChar_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperWCharPubSubType::~MapInnerAliasBoundedStringHelperWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -42550,16 +39683,12 @@ bool MapInnerAliasBoundedStringHelperWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -42568,18 +39697,14 @@ bool MapInnerAliasBoundedStringHelperWCharPubSubType::deserialize( MapInnerAliasBoundedStringHelperWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -42592,52 +39717,62 @@ bool MapInnerAliasBoundedStringHelperWCharPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperWCharPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperWCharPubSubType::createData() +void* MapInnerAliasBoundedStringHelperWCharPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperWChar()); } -void MapInnerAliasBoundedStringHelperWCharPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperWCharPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -42645,35 +39780,27 @@ bool MapInnerAliasBoundedStringHelperWCharPubSubType::getKey( const MapInnerAliasBoundedStringHelperWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -42686,49 +39813,42 @@ void MapInnerAliasBoundedStringHelperWCharPubSubType::register_type_object_repre MapInnerAliasBoundedStringHelperStringPubSubType::MapInnerAliasBoundedStringHelperStringPubSubType() { - setName("MapInnerAliasBoundedStringHelperString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperString::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperString_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperString"); + uint32_t type_size = MapInnerAliasBoundedStringHelperString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperString_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperString_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperStringPubSubType::~MapInnerAliasBoundedStringHelperStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -42743,16 +39863,12 @@ bool MapInnerAliasBoundedStringHelperStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -42761,18 +39877,14 @@ bool MapInnerAliasBoundedStringHelperStringPubSubType::deserialize( MapInnerAliasBoundedStringHelperString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -42785,52 +39897,62 @@ bool MapInnerAliasBoundedStringHelperStringPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperStringPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperStringPubSubType::createData() +void* MapInnerAliasBoundedStringHelperStringPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperString()); } -void MapInnerAliasBoundedStringHelperStringPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperStringPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -42838,35 +39960,27 @@ bool MapInnerAliasBoundedStringHelperStringPubSubType::getKey( const MapInnerAliasBoundedStringHelperString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -42879,49 +39993,42 @@ void MapInnerAliasBoundedStringHelperStringPubSubType::register_type_object_repr MapInnerAliasBoundedStringHelperWStringPubSubType::MapInnerAliasBoundedStringHelperWStringPubSubType() { - setName("MapInnerAliasBoundedStringHelperWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperWString::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperWString_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperWString"); + uint32_t type_size = MapInnerAliasBoundedStringHelperWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperWString_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperWString_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperWStringPubSubType::~MapInnerAliasBoundedStringHelperWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -42936,16 +40043,12 @@ bool MapInnerAliasBoundedStringHelperWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -42954,18 +40057,14 @@ bool MapInnerAliasBoundedStringHelperWStringPubSubType::deserialize( MapInnerAliasBoundedStringHelperWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -42978,52 +40077,62 @@ bool MapInnerAliasBoundedStringHelperWStringPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperWStringPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperWStringPubSubType::createData() +void* MapInnerAliasBoundedStringHelperWStringPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperWString()); } -void MapInnerAliasBoundedStringHelperWStringPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperWStringPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -43031,35 +40140,27 @@ bool MapInnerAliasBoundedStringHelperWStringPubSubType::getKey( const MapInnerAliasBoundedStringHelperWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -43072,49 +40173,42 @@ void MapInnerAliasBoundedStringHelperWStringPubSubType::register_type_object_rep MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType() { - setName("MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -43129,16 +40223,12 @@ bool MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::se } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -43147,18 +40237,14 @@ bool MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::de MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -43171,52 +40257,62 @@ bool MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::de return true; } -std::function MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::createData() +void* MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper()); } -void MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -43224,35 +40320,27 @@ bool MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::ge const MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -43265,49 +40353,42 @@ void MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType::re MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType() { - setName("MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -43322,16 +40403,12 @@ bool MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::s } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -43340,18 +40417,14 @@ bool MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::d MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -43364,52 +40437,62 @@ bool MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::d return true; } -std::function MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::createData() +void* MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper()); } -void MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -43417,35 +40500,27 @@ bool MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::g const MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -43458,49 +40533,42 @@ void MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType::r MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType() { - setName("MapInnerAliasBoundedStringHelperInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerEnumHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerEnumHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperInnerEnumHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerEnumHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerEnumHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperInnerEnumHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -43515,16 +40583,12 @@ bool MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -43533,18 +40597,14 @@ bool MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::deserialize( MapInnerAliasBoundedStringHelperInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -43557,52 +40617,62 @@ bool MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::createData() +void* MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerEnumHelper()); } -void MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -43610,35 +40680,27 @@ bool MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::getKey( const MapInnerAliasBoundedStringHelperInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -43651,49 +40713,42 @@ void MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType::register_type_ob MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType() { - setName("MapInnerAliasBoundedStringHelperInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerBitMaskHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperInnerBitMaskHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -43708,16 +40763,12 @@ bool MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -43726,18 +40777,14 @@ bool MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::deserialize( MapInnerAliasBoundedStringHelperInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -43750,52 +40797,62 @@ bool MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::createData() +void* MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerBitMaskHelper()); } -void MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -43803,35 +40860,27 @@ bool MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::getKey( const MapInnerAliasBoundedStringHelperInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperInnerBitMaskHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperInnerBitMaskHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -43844,49 +40893,42 @@ void MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType::register_type MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType() { - setName("MapInnerAliasBoundedStringHelperInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerAliasHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerAliasHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperInnerAliasHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerAliasHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerAliasHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperInnerAliasHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -43901,16 +40943,12 @@ bool MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -43919,18 +40957,14 @@ bool MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::deserialize( MapInnerAliasBoundedStringHelperInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -43943,52 +40977,62 @@ bool MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::createData() +void* MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerAliasHelper()); } -void MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -43996,35 +41040,27 @@ bool MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::getKey( const MapInnerAliasBoundedStringHelperInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -44037,49 +41073,42 @@ void MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType::register_type_o MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType() { - setName("MapInnerAliasBoundedStringHelperInnerAliasArrayHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerAliasArrayHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerAliasArrayHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperInnerAliasArrayHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerAliasArrayHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasArrayHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasArrayHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -44094,16 +41123,12 @@ bool MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -44112,18 +41137,14 @@ bool MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::deserializ MapInnerAliasBoundedStringHelperInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -44136,52 +41157,62 @@ bool MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::deserializ return true; } -std::function MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::createData() +void* MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerAliasArrayHelper()); } -void MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperInnerAliasArrayHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -44189,35 +41220,27 @@ bool MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::getKey( const MapInnerAliasBoundedStringHelperInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperInnerAliasArrayHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperInnerAliasArrayHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -44230,49 +41253,42 @@ void MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType::register_t MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType() { - setName("MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -44287,16 +41303,12 @@ bool MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::seriali } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -44305,18 +41317,14 @@ bool MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::deseria MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -44329,52 +41337,62 @@ bool MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::deseria return true; } -std::function MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::createData() +void* MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper()); } -void MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -44382,35 +41400,27 @@ bool MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::getKey( const MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -44423,49 +41433,42 @@ void MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType::registe MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType() { - setName("MapInnerAliasBoundedStringHelperInnerAliasMapHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerAliasMapHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerAliasMapHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperInnerAliasMapHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerAliasMapHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasMapHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerAliasMapHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -44480,16 +41483,12 @@ bool MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -44498,18 +41497,14 @@ bool MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::deserialize( MapInnerAliasBoundedStringHelperInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -44522,52 +41517,62 @@ bool MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::createData() +void* MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerAliasMapHelper()); } -void MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperInnerAliasMapHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -44575,35 +41580,27 @@ bool MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::getKey( const MapInnerAliasBoundedStringHelperInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperInnerAliasMapHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperInnerAliasMapHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -44616,49 +41613,42 @@ void MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType::register_typ MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType() { - setName("MapInnerAliasBoundedStringHelperInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerUnionHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerUnionHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperInnerUnionHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerUnionHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerUnionHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperInnerUnionHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedStringHelperInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -44673,16 +41663,12 @@ bool MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -44691,18 +41677,14 @@ bool MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::deserialize( MapInnerAliasBoundedStringHelperInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -44715,336 +41697,138 @@ bool MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::createData() -{ - return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerUnionHelper()); -} - -void MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) + try { - return false; + 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*/; } - - const MapInnerAliasBoundedStringHelperInnerUnionHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapInnerAliasBoundedStringHelperInnerUnionHelper_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapInnerAliasBoundedStringHelperInnerUnionHelper_max_key_cdr_typesize > 16) + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + return 0; } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -void MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::register_type_object_representation() -{ - register_MapInnerAliasBoundedStringHelperInnerUnionHelper_type_identifier(type_identifiers_); } -MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType() +void* MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::create_data() { - setName("MapInnerAliasBoundedStringHelperInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerStructureHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerStructureHelper_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerStructureHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerUnionHelper()); } -MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType() +void MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::delete_data( + void* data) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } + delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) +bool MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - const MapInnerAliasBoundedStringHelperInnerStructureHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapInnerAliasBoundedStringHelperInnerStructureHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapInnerAliasBoundedStringHelperInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::createData() -{ - return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerStructureHelper()); -} - -void MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const MapInnerAliasBoundedStringHelperInnerStructureHelper* p_type = static_cast(data); + const MapInnerAliasBoundedStringHelperInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapInnerAliasBoundedStringHelperInnerStructureHelper_max_key_cdr_typesize); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapInnerAliasBoundedStringHelperInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapInnerAliasBoundedStringHelperInnerStructureHelper_max_key_cdr_typesize > 16) + if (force_md5 || MapInnerAliasBoundedStringHelperInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } -void MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::register_type_object_representation() +void MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType::register_type_object_representation() { - register_MapInnerAliasBoundedStringHelperInnerStructureHelper_type_identifier(type_identifiers_); + register_MapInnerAliasBoundedStringHelperInnerUnionHelper_type_identifier(type_identifiers_); } -MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType() +MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType() { - setName("MapInnerAliasBoundedStringHelperInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedStringHelperInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedStringHelperInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedStringHelperInnerStructureHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedStringHelperInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedStringHelperInnerStructureHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } -MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType() +MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } -bool MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::serialize( +bool MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const MapInnerAliasBoundedStringHelperInnerBitsetHelper* p_type = static_cast(data); + const MapInnerAliasBoundedStringHelperInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -45059,16 +41843,192 @@ bool MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapInnerAliasBoundedStringHelperInnerStructureHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // 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 MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::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* MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::create_data() +{ + return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerStructureHelper()); +} + +void MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapInnerAliasBoundedStringHelperInnerStructureHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapInnerAliasBoundedStringHelperInnerStructureHelper_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapInnerAliasBoundedStringHelperInnerStructureHelper_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 MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType::register_type_object_representation() +{ + register_MapInnerAliasBoundedStringHelperInnerStructureHelper_type_identifier(type_identifiers_); +} + +MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType() +{ + set_name("MapInnerAliasBoundedStringHelperInnerBitsetHelper"); + uint32_t type_size = MapInnerAliasBoundedStringHelperInnerBitsetHelper_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 = MapInnerAliasBoundedStringHelperInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedStringHelperInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::~MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapInnerAliasBoundedStringHelperInnerBitsetHelper* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -45077,18 +42037,14 @@ bool MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::deserialize( MapInnerAliasBoundedStringHelperInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -45101,52 +42057,62 @@ bool MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::createData() +void* MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedStringHelperInnerBitsetHelper()); } -void MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::deleteData( +void MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::getKey( +bool MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedStringHelperInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -45154,35 +42120,27 @@ bool MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::getKey( const MapInnerAliasBoundedStringHelperInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedStringHelperInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedStringHelperInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -45195,49 +42153,42 @@ void MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType::register_type_ MapInnerAliasBoundedWStringHelperShortPubSubType::MapInnerAliasBoundedWStringHelperShortPubSubType() { - setName("MapInnerAliasBoundedWStringHelperShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperShort::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperShort_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperShort"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperShort_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperShort_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperShortPubSubType::~MapInnerAliasBoundedWStringHelperShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -45252,16 +42203,12 @@ bool MapInnerAliasBoundedWStringHelperShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -45270,18 +42217,14 @@ bool MapInnerAliasBoundedWStringHelperShortPubSubType::deserialize( MapInnerAliasBoundedWStringHelperShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -45294,52 +42237,62 @@ bool MapInnerAliasBoundedWStringHelperShortPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperShortPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperShortPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperShortPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperShort()); } -void MapInnerAliasBoundedWStringHelperShortPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperShortPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -45347,35 +42300,27 @@ bool MapInnerAliasBoundedWStringHelperShortPubSubType::getKey( const MapInnerAliasBoundedWStringHelperShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -45388,49 +42333,42 @@ void MapInnerAliasBoundedWStringHelperShortPubSubType::register_type_object_repr MapInnerAliasBoundedWStringHelperUShortPubSubType::MapInnerAliasBoundedWStringHelperUShortPubSubType() { - setName("MapInnerAliasBoundedWStringHelperUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperUShort::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperUShort_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperUShort"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperUShort_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperUShort_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperUShortPubSubType::~MapInnerAliasBoundedWStringHelperUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -45445,16 +42383,12 @@ bool MapInnerAliasBoundedWStringHelperUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -45463,18 +42397,14 @@ bool MapInnerAliasBoundedWStringHelperUShortPubSubType::deserialize( MapInnerAliasBoundedWStringHelperUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -45487,52 +42417,62 @@ bool MapInnerAliasBoundedWStringHelperUShortPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperUShortPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperUShortPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperUShortPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperUShort()); } -void MapInnerAliasBoundedWStringHelperUShortPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperUShortPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -45540,35 +42480,27 @@ bool MapInnerAliasBoundedWStringHelperUShortPubSubType::getKey( const MapInnerAliasBoundedWStringHelperUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -45581,49 +42513,42 @@ void MapInnerAliasBoundedWStringHelperUShortPubSubType::register_type_object_rep MapInnerAliasBoundedWStringHelperLongPubSubType::MapInnerAliasBoundedWStringHelperLongPubSubType() { - setName("MapInnerAliasBoundedWStringHelperLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperLong::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperLong_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperLong"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperLongPubSubType::~MapInnerAliasBoundedWStringHelperLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -45638,16 +42563,12 @@ bool MapInnerAliasBoundedWStringHelperLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -45656,18 +42577,14 @@ bool MapInnerAliasBoundedWStringHelperLongPubSubType::deserialize( MapInnerAliasBoundedWStringHelperLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -45680,52 +42597,62 @@ bool MapInnerAliasBoundedWStringHelperLongPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperLongPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperLongPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperLongPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperLong()); } -void MapInnerAliasBoundedWStringHelperLongPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperLongPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -45733,35 +42660,27 @@ bool MapInnerAliasBoundedWStringHelperLongPubSubType::getKey( const MapInnerAliasBoundedWStringHelperLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -45774,49 +42693,42 @@ void MapInnerAliasBoundedWStringHelperLongPubSubType::register_type_object_repre MapInnerAliasBoundedWStringHelperULongPubSubType::MapInnerAliasBoundedWStringHelperULongPubSubType() { - setName("MapInnerAliasBoundedWStringHelperULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperULong::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperULong_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperULong"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperULong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperULong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperULongPubSubType::~MapInnerAliasBoundedWStringHelperULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -45831,16 +42743,12 @@ bool MapInnerAliasBoundedWStringHelperULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -45849,18 +42757,14 @@ bool MapInnerAliasBoundedWStringHelperULongPubSubType::deserialize( MapInnerAliasBoundedWStringHelperULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -45873,52 +42777,62 @@ bool MapInnerAliasBoundedWStringHelperULongPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperULongPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperULongPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperULongPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperULong()); } -void MapInnerAliasBoundedWStringHelperULongPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperULongPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -45926,35 +42840,27 @@ bool MapInnerAliasBoundedWStringHelperULongPubSubType::getKey( const MapInnerAliasBoundedWStringHelperULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -45967,49 +42873,42 @@ void MapInnerAliasBoundedWStringHelperULongPubSubType::register_type_object_repr MapInnerAliasBoundedWStringHelperLongLongPubSubType::MapInnerAliasBoundedWStringHelperLongLongPubSubType() { - setName("MapInnerAliasBoundedWStringHelperLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperLongLong::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperLongLong_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperLongLong"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperLongLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperLongLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperLongLongPubSubType::~MapInnerAliasBoundedWStringHelperLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -46024,16 +42923,12 @@ bool MapInnerAliasBoundedWStringHelperLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -46042,18 +42937,14 @@ bool MapInnerAliasBoundedWStringHelperLongLongPubSubType::deserialize( MapInnerAliasBoundedWStringHelperLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -46066,52 +42957,62 @@ bool MapInnerAliasBoundedWStringHelperLongLongPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperLongLongPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperLongLongPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperLongLongPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperLongLong()); } -void MapInnerAliasBoundedWStringHelperLongLongPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperLongLongPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -46119,35 +43020,27 @@ bool MapInnerAliasBoundedWStringHelperLongLongPubSubType::getKey( const MapInnerAliasBoundedWStringHelperLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -46160,49 +43053,42 @@ void MapInnerAliasBoundedWStringHelperLongLongPubSubType::register_type_object_r MapInnerAliasBoundedWStringHelperULongLongPubSubType::MapInnerAliasBoundedWStringHelperULongLongPubSubType() { - setName("MapInnerAliasBoundedWStringHelperULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperULongLong::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperULongLong_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperULongLong"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperULongLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperULongLong_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperULongLongPubSubType::~MapInnerAliasBoundedWStringHelperULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -46217,16 +43103,12 @@ bool MapInnerAliasBoundedWStringHelperULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -46235,18 +43117,14 @@ bool MapInnerAliasBoundedWStringHelperULongLongPubSubType::deserialize( MapInnerAliasBoundedWStringHelperULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -46259,52 +43137,62 @@ bool MapInnerAliasBoundedWStringHelperULongLongPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperULongLongPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperULongLongPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperULongLongPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperULongLong()); } -void MapInnerAliasBoundedWStringHelperULongLongPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperULongLongPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -46312,35 +43200,27 @@ bool MapInnerAliasBoundedWStringHelperULongLongPubSubType::getKey( const MapInnerAliasBoundedWStringHelperULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -46353,49 +43233,42 @@ void MapInnerAliasBoundedWStringHelperULongLongPubSubType::register_type_object_ MapInnerAliasBoundedWStringHelperFloatPubSubType::MapInnerAliasBoundedWStringHelperFloatPubSubType() { - setName("MapInnerAliasBoundedWStringHelperFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperFloat::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperFloat_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperFloat"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperFloat_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperFloat_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperFloatPubSubType::~MapInnerAliasBoundedWStringHelperFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -46410,16 +43283,12 @@ bool MapInnerAliasBoundedWStringHelperFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -46428,18 +43297,14 @@ bool MapInnerAliasBoundedWStringHelperFloatPubSubType::deserialize( MapInnerAliasBoundedWStringHelperFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -46452,52 +43317,62 @@ bool MapInnerAliasBoundedWStringHelperFloatPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperFloatPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperFloatPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperFloatPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperFloat()); } -void MapInnerAliasBoundedWStringHelperFloatPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperFloatPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -46505,35 +43380,27 @@ bool MapInnerAliasBoundedWStringHelperFloatPubSubType::getKey( const MapInnerAliasBoundedWStringHelperFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -46546,49 +43413,42 @@ void MapInnerAliasBoundedWStringHelperFloatPubSubType::register_type_object_repr MapInnerAliasBoundedWStringHelperDoublePubSubType::MapInnerAliasBoundedWStringHelperDoublePubSubType() { - setName("MapInnerAliasBoundedWStringHelperDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperDouble::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperDouble_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperDouble"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperDouble_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperDouble_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperDoublePubSubType::~MapInnerAliasBoundedWStringHelperDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -46603,16 +43463,12 @@ bool MapInnerAliasBoundedWStringHelperDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -46621,18 +43477,14 @@ bool MapInnerAliasBoundedWStringHelperDoublePubSubType::deserialize( MapInnerAliasBoundedWStringHelperDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -46645,52 +43497,62 @@ bool MapInnerAliasBoundedWStringHelperDoublePubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperDoublePubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperDoublePubSubType::createData() +void* MapInnerAliasBoundedWStringHelperDoublePubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperDouble()); } -void MapInnerAliasBoundedWStringHelperDoublePubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperDoublePubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -46698,35 +43560,27 @@ bool MapInnerAliasBoundedWStringHelperDoublePubSubType::getKey( const MapInnerAliasBoundedWStringHelperDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -46739,49 +43593,42 @@ void MapInnerAliasBoundedWStringHelperDoublePubSubType::register_type_object_rep MapInnerAliasBoundedWStringHelperLongDoublePubSubType::MapInnerAliasBoundedWStringHelperLongDoublePubSubType() { - setName("MapInnerAliasBoundedWStringHelperLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperLongDouble::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperLongDouble_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperLongDouble"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperLongDouble_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperLongDouble_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperLongDoublePubSubType::~MapInnerAliasBoundedWStringHelperLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -46796,16 +43643,12 @@ bool MapInnerAliasBoundedWStringHelperLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -46814,18 +43657,14 @@ bool MapInnerAliasBoundedWStringHelperLongDoublePubSubType::deserialize( MapInnerAliasBoundedWStringHelperLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -46838,52 +43677,62 @@ bool MapInnerAliasBoundedWStringHelperLongDoublePubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperLongDoublePubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperLongDoublePubSubType::createData() +void* MapInnerAliasBoundedWStringHelperLongDoublePubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperLongDouble()); } -void MapInnerAliasBoundedWStringHelperLongDoublePubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperLongDoublePubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -46891,35 +43740,27 @@ bool MapInnerAliasBoundedWStringHelperLongDoublePubSubType::getKey( const MapInnerAliasBoundedWStringHelperLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -46932,49 +43773,42 @@ void MapInnerAliasBoundedWStringHelperLongDoublePubSubType::register_type_object MapInnerAliasBoundedWStringHelperBooleanPubSubType::MapInnerAliasBoundedWStringHelperBooleanPubSubType() { - setName("MapInnerAliasBoundedWStringHelperBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperBoolean::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperBoolean_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperBoolean"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperBoolean_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperBoolean_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperBooleanPubSubType::~MapInnerAliasBoundedWStringHelperBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -46989,16 +43823,12 @@ bool MapInnerAliasBoundedWStringHelperBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -47007,18 +43837,14 @@ bool MapInnerAliasBoundedWStringHelperBooleanPubSubType::deserialize( MapInnerAliasBoundedWStringHelperBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -47031,52 +43857,62 @@ bool MapInnerAliasBoundedWStringHelperBooleanPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperBooleanPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperBooleanPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperBooleanPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperBoolean()); } -void MapInnerAliasBoundedWStringHelperBooleanPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperBooleanPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -47084,35 +43920,27 @@ bool MapInnerAliasBoundedWStringHelperBooleanPubSubType::getKey( const MapInnerAliasBoundedWStringHelperBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -47125,49 +43953,42 @@ void MapInnerAliasBoundedWStringHelperBooleanPubSubType::register_type_object_re MapInnerAliasBoundedWStringHelperOctetPubSubType::MapInnerAliasBoundedWStringHelperOctetPubSubType() { - setName("MapInnerAliasBoundedWStringHelperOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperOctet::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperOctet_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperOctet"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperOctet_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperOctet_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperOctetPubSubType::~MapInnerAliasBoundedWStringHelperOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -47182,16 +44003,12 @@ bool MapInnerAliasBoundedWStringHelperOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -47200,18 +44017,14 @@ bool MapInnerAliasBoundedWStringHelperOctetPubSubType::deserialize( MapInnerAliasBoundedWStringHelperOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -47224,52 +44037,62 @@ bool MapInnerAliasBoundedWStringHelperOctetPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperOctetPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperOctetPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperOctetPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperOctet()); } -void MapInnerAliasBoundedWStringHelperOctetPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperOctetPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -47277,35 +44100,27 @@ bool MapInnerAliasBoundedWStringHelperOctetPubSubType::getKey( const MapInnerAliasBoundedWStringHelperOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -47318,49 +44133,42 @@ void MapInnerAliasBoundedWStringHelperOctetPubSubType::register_type_object_repr MapInnerAliasBoundedWStringHelperCharPubSubType::MapInnerAliasBoundedWStringHelperCharPubSubType() { - setName("MapInnerAliasBoundedWStringHelperChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperChar::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperChar_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperChar"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperChar_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperChar_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperCharPubSubType::~MapInnerAliasBoundedWStringHelperCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -47375,16 +44183,12 @@ bool MapInnerAliasBoundedWStringHelperCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -47393,18 +44197,14 @@ bool MapInnerAliasBoundedWStringHelperCharPubSubType::deserialize( MapInnerAliasBoundedWStringHelperChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -47417,52 +44217,62 @@ bool MapInnerAliasBoundedWStringHelperCharPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperCharPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperCharPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperCharPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperChar()); } -void MapInnerAliasBoundedWStringHelperCharPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperCharPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -47470,35 +44280,27 @@ bool MapInnerAliasBoundedWStringHelperCharPubSubType::getKey( const MapInnerAliasBoundedWStringHelperChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -47511,49 +44313,42 @@ void MapInnerAliasBoundedWStringHelperCharPubSubType::register_type_object_repre MapInnerAliasBoundedWStringHelperWCharPubSubType::MapInnerAliasBoundedWStringHelperWCharPubSubType() { - setName("MapInnerAliasBoundedWStringHelperWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperWChar::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperWChar_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperWChar"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperWChar_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperWChar_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperWCharPubSubType::~MapInnerAliasBoundedWStringHelperWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -47568,16 +44363,12 @@ bool MapInnerAliasBoundedWStringHelperWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -47586,18 +44377,14 @@ bool MapInnerAliasBoundedWStringHelperWCharPubSubType::deserialize( MapInnerAliasBoundedWStringHelperWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -47610,52 +44397,62 @@ bool MapInnerAliasBoundedWStringHelperWCharPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperWCharPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperWCharPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperWCharPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperWChar()); } -void MapInnerAliasBoundedWStringHelperWCharPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperWCharPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -47663,35 +44460,27 @@ bool MapInnerAliasBoundedWStringHelperWCharPubSubType::getKey( const MapInnerAliasBoundedWStringHelperWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -47704,49 +44493,42 @@ void MapInnerAliasBoundedWStringHelperWCharPubSubType::register_type_object_repr MapInnerAliasBoundedWStringHelperStringPubSubType::MapInnerAliasBoundedWStringHelperStringPubSubType() { - setName("MapInnerAliasBoundedWStringHelperString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperString::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperString_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperString"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperString_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperString_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperStringPubSubType::~MapInnerAliasBoundedWStringHelperStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -47761,16 +44543,12 @@ bool MapInnerAliasBoundedWStringHelperStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -47779,18 +44557,14 @@ bool MapInnerAliasBoundedWStringHelperStringPubSubType::deserialize( MapInnerAliasBoundedWStringHelperString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -47803,52 +44577,62 @@ bool MapInnerAliasBoundedWStringHelperStringPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperStringPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperStringPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperStringPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperString()); } -void MapInnerAliasBoundedWStringHelperStringPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperStringPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -47856,35 +44640,27 @@ bool MapInnerAliasBoundedWStringHelperStringPubSubType::getKey( const MapInnerAliasBoundedWStringHelperString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -47897,49 +44673,42 @@ void MapInnerAliasBoundedWStringHelperStringPubSubType::register_type_object_rep MapInnerAliasBoundedWStringHelperWStringPubSubType::MapInnerAliasBoundedWStringHelperWStringPubSubType() { - setName("MapInnerAliasBoundedWStringHelperWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperWString::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperWString_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperWString"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperWString_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperWString_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperWStringPubSubType::~MapInnerAliasBoundedWStringHelperWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -47954,16 +44723,12 @@ bool MapInnerAliasBoundedWStringHelperWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -47972,18 +44737,14 @@ bool MapInnerAliasBoundedWStringHelperWStringPubSubType::deserialize( MapInnerAliasBoundedWStringHelperWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -47996,52 +44757,62 @@ bool MapInnerAliasBoundedWStringHelperWStringPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperWStringPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperWStringPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperWStringPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperWString()); } -void MapInnerAliasBoundedWStringHelperWStringPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperWStringPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -48049,35 +44820,27 @@ bool MapInnerAliasBoundedWStringHelperWStringPubSubType::getKey( const MapInnerAliasBoundedWStringHelperWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -48090,49 +44853,42 @@ void MapInnerAliasBoundedWStringHelperWStringPubSubType::register_type_object_re MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType() { - setName("MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -48147,16 +44903,12 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::s } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -48165,18 +44917,14 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::d MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -48189,52 +44937,62 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::d return true; } -std::function MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper()); } -void MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -48242,35 +45000,27 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::g const MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -48283,49 +45033,42 @@ void MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType::r MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType() { - setName("MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -48340,16 +45083,12 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType:: } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -48358,18 +45097,14 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType:: MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -48382,52 +45117,62 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType:: return true; } -std::function MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper()); } -void MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -48435,35 +45180,27 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType:: const MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -48476,49 +45213,42 @@ void MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType:: MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType() { - setName("MapInnerAliasBoundedWStringHelperInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerEnumHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerEnumHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperInnerEnumHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerEnumHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerEnumHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperInnerEnumHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -48533,16 +45263,12 @@ bool MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -48551,18 +45277,14 @@ bool MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::deserialize( MapInnerAliasBoundedWStringHelperInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -48575,52 +45297,62 @@ bool MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerEnumHelper()); } -void MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -48628,35 +45360,27 @@ bool MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::getKey( const MapInnerAliasBoundedWStringHelperInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -48669,49 +45393,42 @@ void MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType::register_type_o MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType() { - setName("MapInnerAliasBoundedWStringHelperInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperInnerBitMaskHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -48726,16 +45443,12 @@ bool MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -48744,18 +45457,194 @@ bool MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::deserialize( MapInnerAliasBoundedWStringHelperInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + 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 MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::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* MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::create_data() +{ + return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerBitMaskHelper()); +} + +void MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MapInnerAliasBoundedWStringHelperInnerBitMaskHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_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 MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::register_type_object_representation() +{ + register_MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_type_identifier(type_identifiers_); +} + +MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType() +{ + set_name("MapInnerAliasBoundedWStringHelperInnerAliasHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerAliasHelper_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 = MapInnerAliasBoundedWStringHelperInnerAliasHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MapInnerAliasBoundedWStringHelperInnerAliasHelper* 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; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MapInnerAliasBoundedWStringHelperInnerAliasHelper* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -48768,245 +45657,62 @@ bool MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::createData() -{ - return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerBitMaskHelper()); -} - -void MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - const MapInnerAliasBoundedWStringHelperInnerBitMaskHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_max_key_cdr_typesize > 16) + try { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } + 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*/; } - else + catch (eprosima::fastcdr::exception::Exception& /*exception*/) { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } + return 0; } - return true; } -void MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType::register_type_object_representation() +void* MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::create_data() { - register_MapInnerAliasBoundedWStringHelperInnerBitMaskHelper_type_identifier(type_identifiers_); + return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerAliasHelper()); } -MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType() +void MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::delete_data( + void* data) { - setName("MapInnerAliasBoundedWStringHelperInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerAliasHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerAliasHelper_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerAliasHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + delete(reinterpret_cast(data)); } -MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType() +bool MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - const MapInnerAliasBoundedWStringHelperInnerAliasHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + if (!is_compute_key_provided) { return false; } - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MapInnerAliasBoundedWStringHelperInnerAliasHelper* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + MapInnerAliasBoundedWStringHelperInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) { - return false; + return compute_key(static_cast(&data), handle, force_md5); } - return true; -} - -std::function MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::createData() -{ - return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerAliasHelper()); -} - -void MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); + return false; } -bool MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -49014,35 +45720,27 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::getKey( const MapInnerAliasBoundedWStringHelperInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -49055,49 +45753,42 @@ void MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType::register_type_ MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType() { - setName("MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -49112,16 +45803,12 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::serialize } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -49130,18 +45817,14 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::deseriali MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -49154,52 +45837,62 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::deseriali return true; } -std::function MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper()); } -void MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -49207,35 +45900,27 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::getKey( const MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperInnerAliasArrayHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -49248,49 +45933,42 @@ void MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType::register_ MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType() { - setName("MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -49305,16 +45983,12 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::serial } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -49323,18 +45997,14 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::deseri MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -49347,52 +46017,62 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::deseri return true; } -std::function MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper()); } -void MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -49400,35 +46080,27 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::getKey const MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -49441,49 +46113,42 @@ void MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType::regist MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType() { - setName("MapInnerAliasBoundedWStringHelperInnerAliasMapHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerAliasMapHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerAliasMapHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperInnerAliasMapHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerAliasMapHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasMapHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperInnerAliasMapHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerAliasMapHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -49498,16 +46163,12 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -49516,18 +46177,14 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::deserialize MapInnerAliasBoundedWStringHelperInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -49540,52 +46197,62 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::deserialize return true; } -std::function MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerAliasMapHelper()); } -void MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperInnerAliasMapHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -49593,35 +46260,27 @@ bool MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::getKey( const MapInnerAliasBoundedWStringHelperInnerAliasMapHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperInnerAliasMapHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperInnerAliasMapHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -49634,49 +46293,42 @@ void MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType::register_ty MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType() { - setName("MapInnerAliasBoundedWStringHelperInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerUnionHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerUnionHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperInnerUnionHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerUnionHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerUnionHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperInnerUnionHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -49691,16 +46343,12 @@ bool MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -49709,18 +46357,14 @@ bool MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::deserialize( MapInnerAliasBoundedWStringHelperInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -49733,52 +46377,62 @@ bool MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerUnionHelper()); } -void MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -49786,35 +46440,27 @@ bool MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::getKey( const MapInnerAliasBoundedWStringHelperInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -49827,49 +46473,42 @@ void MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType::register_type_ MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType() { - setName("MapInnerAliasBoundedWStringHelperInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerStructureHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerStructureHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperInnerStructureHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerStructureHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperInnerStructureHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -49884,16 +46523,12 @@ bool MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -49902,18 +46537,14 @@ bool MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::deserializ MapInnerAliasBoundedWStringHelperInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -49926,52 +46557,62 @@ bool MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::deserializ return true; } -std::function MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerStructureHelper()); } -void MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -49979,35 +46620,27 @@ bool MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::getKey( const MapInnerAliasBoundedWStringHelperInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperInnerStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperInnerStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -50020,49 +46653,42 @@ void MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType::register_t MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType() { - setName("MapInnerAliasBoundedWStringHelperInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapInnerAliasBoundedWStringHelperInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - MapInnerAliasBoundedWStringHelperInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("MapInnerAliasBoundedWStringHelperInnerBitsetHelper"); + uint32_t type_size = MapInnerAliasBoundedWStringHelperInnerBitsetHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapInnerAliasBoundedWStringHelperInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapInnerAliasBoundedWStringHelperInnerBitsetHelper_max_key_cdr_typesize > 16 ? MapInnerAliasBoundedWStringHelperInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::~MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapInnerAliasBoundedWStringHelperInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -50077,16 +46703,12 @@ bool MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -50095,18 +46717,14 @@ bool MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::deserialize( MapInnerAliasBoundedWStringHelperInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -50119,52 +46737,62 @@ bool MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::deserialize( return true; } -std::function MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::createData() +void* MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::create_data() { return reinterpret_cast(new MapInnerAliasBoundedWStringHelperInnerBitsetHelper()); } -void MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::deleteData( +void MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::getKey( +bool MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapInnerAliasBoundedWStringHelperInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -50172,35 +46800,27 @@ bool MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::getKey( const MapInnerAliasBoundedWStringHelperInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapInnerAliasBoundedWStringHelperInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapInnerAliasBoundedWStringHelperInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -50213,49 +46833,42 @@ void MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType::register_type BoundedSmallMapPubSubType::BoundedSmallMapPubSubType() { - setName("BoundedSmallMap"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BoundedSmallMap::getMaxCdrSerializedSize()); -#else - BoundedSmallMap_max_cdr_typesize; -#endif + set_name("BoundedSmallMap"); + uint32_t type_size = BoundedSmallMap_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BoundedSmallMap_max_key_cdr_typesize > 16 ? BoundedSmallMap_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BoundedSmallMap_max_key_cdr_typesize > 16 ? BoundedSmallMap_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BoundedSmallMapPubSubType::~BoundedSmallMapPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BoundedSmallMapPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BoundedSmallMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -50270,16 +46883,12 @@ bool BoundedSmallMapPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BoundedSmallMapPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -50288,18 +46897,14 @@ bool BoundedSmallMapPubSubType::deserialize( BoundedSmallMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -50312,52 +46917,62 @@ bool BoundedSmallMapPubSubType::deserialize( return true; } -std::function BoundedSmallMapPubSubType::getSerializedSizeProvider( +uint32_t BoundedSmallMapPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* BoundedSmallMapPubSubType::createData() +void* BoundedSmallMapPubSubType::create_data() { return reinterpret_cast(new BoundedSmallMap()); } -void BoundedSmallMapPubSubType::deleteData( +void BoundedSmallMapPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BoundedSmallMapPubSubType::getKey( +bool BoundedSmallMapPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BoundedSmallMap data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BoundedSmallMapPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -50365,35 +46980,27 @@ bool BoundedSmallMapPubSubType::getKey( const BoundedSmallMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BoundedSmallMap_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BoundedSmallMap_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -50406,49 +47013,42 @@ void BoundedSmallMapPubSubType::register_type_object_representation() BoundedLargeMapPubSubType::BoundedLargeMapPubSubType() { - setName("BoundedLargeMap"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BoundedLargeMap::getMaxCdrSerializedSize()); -#else - BoundedLargeMap_max_cdr_typesize; -#endif + set_name("BoundedLargeMap"); + uint32_t type_size = BoundedLargeMap_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BoundedLargeMap_max_key_cdr_typesize > 16 ? BoundedLargeMap_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BoundedLargeMap_max_key_cdr_typesize > 16 ? BoundedLargeMap_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BoundedLargeMapPubSubType::~BoundedLargeMapPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BoundedLargeMapPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BoundedLargeMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -50463,16 +47063,12 @@ bool BoundedLargeMapPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BoundedLargeMapPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -50481,18 +47077,14 @@ bool BoundedLargeMapPubSubType::deserialize( BoundedLargeMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -50505,52 +47097,62 @@ bool BoundedLargeMapPubSubType::deserialize( return true; } -std::function BoundedLargeMapPubSubType::getSerializedSizeProvider( +uint32_t BoundedLargeMapPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* BoundedLargeMapPubSubType::createData() +void* BoundedLargeMapPubSubType::create_data() { return reinterpret_cast(new BoundedLargeMap()); } -void BoundedLargeMapPubSubType::deleteData( +void BoundedLargeMapPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BoundedLargeMapPubSubType::getKey( +bool BoundedLargeMapPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BoundedLargeMap data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BoundedLargeMapPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -50558,35 +47160,27 @@ bool BoundedLargeMapPubSubType::getKey( const BoundedLargeMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BoundedLargeMap_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BoundedLargeMap_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/mapsPubSubTypes.hpp b/test/dds-types-test/mapsPubSubTypes.hpp index 34c1d60871e..db82899c968 100644 --- a/test/dds-types-test/mapsPubSubTypes.hpp +++ b/test/dds-types-test/mapsPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated maps is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class MapShortShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class MapShortShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class MapShortShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class MapShortUShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class MapShortUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class MapShortUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -237,38 +217,30 @@ class MapShortLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -283,10 +255,6 @@ class MapShortLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,8 +275,10 @@ class MapShortLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -328,38 +298,30 @@ class MapShortULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -374,10 +336,6 @@ class MapShortULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -398,8 +356,10 @@ class MapShortULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -419,38 +379,30 @@ class MapShortLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -465,10 +417,6 @@ class MapShortLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -489,8 +437,10 @@ class MapShortLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -510,38 +460,30 @@ class MapShortULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -556,10 +498,6 @@ class MapShortULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -580,8 +518,10 @@ class MapShortULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -601,38 +541,30 @@ class MapShortFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -647,10 +579,6 @@ class MapShortFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -671,8 +599,10 @@ class MapShortFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -692,38 +622,30 @@ class MapShortDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -738,10 +660,6 @@ class MapShortDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -762,8 +680,10 @@ class MapShortDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -783,38 +703,30 @@ class MapShortLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -829,10 +741,6 @@ class MapShortLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -853,8 +761,10 @@ class MapShortLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -874,38 +784,30 @@ class MapShortBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -920,10 +822,6 @@ class MapShortBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -944,8 +842,10 @@ class MapShortBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -965,38 +865,30 @@ class MapShortOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1011,10 +903,6 @@ class MapShortOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1035,8 +923,10 @@ class MapShortOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1056,38 +946,30 @@ class MapShortCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1102,10 +984,6 @@ class MapShortCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1126,8 +1004,10 @@ class MapShortCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1147,38 +1027,30 @@ class MapShortWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1193,10 +1065,6 @@ class MapShortWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1217,8 +1085,10 @@ class MapShortWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1238,38 +1108,30 @@ class MapShortStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1284,10 +1146,6 @@ class MapShortStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1308,8 +1166,10 @@ class MapShortStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1329,38 +1189,30 @@ class MapShortWStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1375,10 +1227,6 @@ class MapShortWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1399,8 +1247,10 @@ class MapShortWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1420,38 +1270,30 @@ class MapShortInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1466,10 +1308,6 @@ class MapShortInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1490,8 +1328,10 @@ class MapShortInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1511,38 +1351,30 @@ class MapShortInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1557,10 +1389,6 @@ class MapShortInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1581,8 +1409,10 @@ class MapShortInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1602,38 +1432,30 @@ class MapShortInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1648,10 +1470,6 @@ class MapShortInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1672,8 +1490,10 @@ class MapShortInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1693,38 +1513,30 @@ class MapShortInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1739,10 +1551,6 @@ class MapShortInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1763,8 +1571,10 @@ class MapShortInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1784,38 +1594,30 @@ class MapShortInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1830,10 +1632,6 @@ class MapShortInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1854,8 +1652,10 @@ class MapShortInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1875,38 +1675,30 @@ class MapShortInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1921,10 +1713,6 @@ class MapShortInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1945,8 +1733,10 @@ class MapShortInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1966,38 +1756,30 @@ class MapShortInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2012,10 +1794,6 @@ class MapShortInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2036,8 +1814,10 @@ class MapShortInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2057,38 +1837,30 @@ class MapShortInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2103,10 +1875,6 @@ class MapShortInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2127,8 +1895,10 @@ class MapShortInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2148,38 +1918,30 @@ class MapShortInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2194,10 +1956,6 @@ class MapShortInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2218,8 +1976,10 @@ class MapShortInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2239,38 +1999,30 @@ class MapShortInnerStructureHelperPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2285,10 +2037,6 @@ class MapShortInnerStructureHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2309,8 +2057,10 @@ class MapShortInnerStructureHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2330,38 +2080,30 @@ class MapShortInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2376,10 +2118,6 @@ class MapShortInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2400,8 +2138,10 @@ class MapShortInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2421,38 +2161,30 @@ class MapUShortShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2467,10 +2199,6 @@ class MapUShortShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2491,8 +2219,10 @@ class MapUShortShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2512,38 +2242,30 @@ class MapUShortUShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2558,10 +2280,6 @@ class MapUShortUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2582,8 +2300,10 @@ class MapUShortUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2603,38 +2323,30 @@ class MapUShortLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2649,10 +2361,6 @@ class MapUShortLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2673,8 +2381,10 @@ class MapUShortLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2694,38 +2404,30 @@ class MapUShortULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2740,10 +2442,6 @@ class MapUShortULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2764,8 +2462,10 @@ class MapUShortULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2785,38 +2485,30 @@ class MapUShortLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2831,10 +2523,6 @@ class MapUShortLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2855,8 +2543,10 @@ class MapUShortLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2876,38 +2566,30 @@ class MapUShortULongLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2922,10 +2604,6 @@ class MapUShortULongLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2946,8 +2624,10 @@ class MapUShortULongLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2967,38 +2647,30 @@ class MapUShortFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3013,10 +2685,6 @@ class MapUShortFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3037,8 +2705,10 @@ class MapUShortFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3058,38 +2728,30 @@ class MapUShortDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3104,10 +2766,6 @@ class MapUShortDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3128,8 +2786,10 @@ class MapUShortDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3149,38 +2809,30 @@ class MapUShortLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3195,10 +2847,6 @@ class MapUShortLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3219,8 +2867,10 @@ class MapUShortLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3240,38 +2890,30 @@ class MapUShortBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3286,10 +2928,6 @@ class MapUShortBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3310,8 +2948,10 @@ class MapUShortBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3331,38 +2971,30 @@ class MapUShortOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3377,10 +3009,6 @@ class MapUShortOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3401,8 +3029,10 @@ class MapUShortOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3422,38 +3052,30 @@ class MapUShortCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3468,10 +3090,6 @@ class MapUShortCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3492,8 +3110,10 @@ class MapUShortCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3513,38 +3133,30 @@ class MapUShortWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3559,10 +3171,6 @@ class MapUShortWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3583,8 +3191,10 @@ class MapUShortWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3604,38 +3214,30 @@ class MapUShortStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3650,10 +3252,6 @@ class MapUShortStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3674,8 +3272,10 @@ class MapUShortStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3695,38 +3295,30 @@ class MapUShortWStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3741,10 +3333,6 @@ class MapUShortWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3765,8 +3353,10 @@ class MapUShortWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3786,38 +3376,30 @@ class MapUShortInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3832,10 +3414,6 @@ class MapUShortInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3856,8 +3434,10 @@ class MapUShortInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3877,38 +3457,30 @@ class MapUShortInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3923,10 +3495,6 @@ class MapUShortInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3947,8 +3515,10 @@ class MapUShortInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3968,38 +3538,30 @@ class MapUShortInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4014,10 +3576,6 @@ class MapUShortInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4038,8 +3596,10 @@ class MapUShortInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4059,38 +3619,30 @@ class MapUShortInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4105,10 +3657,6 @@ class MapUShortInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4129,8 +3677,10 @@ class MapUShortInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4150,38 +3700,30 @@ class MapUShortInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4196,10 +3738,6 @@ class MapUShortInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4220,8 +3758,10 @@ class MapUShortInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4241,38 +3781,30 @@ class MapUShortInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4287,10 +3819,6 @@ class MapUShortInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4311,8 +3839,10 @@ class MapUShortInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4332,38 +3862,30 @@ class MapUShortInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4378,10 +3900,6 @@ class MapUShortInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4402,8 +3920,10 @@ class MapUShortInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4423,38 +3943,30 @@ class MapUShortInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4469,10 +3981,6 @@ class MapUShortInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4493,8 +4001,10 @@ class MapUShortInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4514,38 +4024,30 @@ class MapUShortInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4560,10 +4062,6 @@ class MapUShortInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4584,8 +4082,10 @@ class MapUShortInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4605,38 +4105,30 @@ class MapUShortInnerStructureHelperPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4651,10 +4143,6 @@ class MapUShortInnerStructureHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4675,8 +4163,10 @@ class MapUShortInnerStructureHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4696,38 +4186,30 @@ class MapUShortInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4742,10 +4224,6 @@ class MapUShortInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4766,8 +4244,10 @@ class MapUShortInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4787,38 +4267,30 @@ class MapLongShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4833,10 +4305,6 @@ class MapLongShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4857,8 +4325,10 @@ class MapLongShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4878,38 +4348,30 @@ class MapLongUShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4924,10 +4386,6 @@ class MapLongUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4948,8 +4406,10 @@ class MapLongUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4969,38 +4429,30 @@ class MapLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5015,10 +4467,6 @@ class MapLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5039,8 +4487,10 @@ class MapLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5060,38 +4510,30 @@ class MapLongULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5106,10 +4548,6 @@ class MapLongULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5130,8 +4568,10 @@ class MapLongULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5151,38 +4591,30 @@ class MapLongKeyLongLongValuePubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5197,10 +4629,6 @@ class MapLongKeyLongLongValuePubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5221,8 +4649,10 @@ class MapLongKeyLongLongValuePubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5242,38 +4672,30 @@ class MapLongULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5288,10 +4710,6 @@ class MapLongULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5312,8 +4730,10 @@ class MapLongULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5333,38 +4753,30 @@ class MapLongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5379,10 +4791,6 @@ class MapLongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5403,8 +4811,10 @@ class MapLongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5424,38 +4834,30 @@ class MapLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5470,10 +4872,6 @@ class MapLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5494,8 +4892,10 @@ class MapLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5515,38 +4915,30 @@ class MapLongKeyLongDoubleValuePubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5561,10 +4953,6 @@ class MapLongKeyLongDoubleValuePubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5585,8 +4973,10 @@ class MapLongKeyLongDoubleValuePubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5606,38 +4996,30 @@ class MapLongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5652,10 +5034,6 @@ class MapLongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5676,8 +5054,10 @@ class MapLongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5697,38 +5077,30 @@ class MapLongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5743,10 +5115,6 @@ class MapLongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5767,8 +5135,10 @@ class MapLongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5788,38 +5158,30 @@ class MapLongCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5834,10 +5196,6 @@ class MapLongCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5858,8 +5216,10 @@ class MapLongCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5879,38 +5239,30 @@ class MapLongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5925,10 +5277,6 @@ class MapLongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5949,8 +5297,10 @@ class MapLongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5970,38 +5320,30 @@ class MapLongStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6016,10 +5358,6 @@ class MapLongStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6040,8 +5378,10 @@ class MapLongStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6061,38 +5401,30 @@ class MapLongWStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6107,10 +5439,6 @@ class MapLongWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6131,8 +5459,10 @@ class MapLongWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6152,38 +5482,30 @@ class MapLongInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6198,10 +5520,6 @@ class MapLongInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6222,8 +5540,10 @@ class MapLongInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6243,38 +5563,30 @@ class MapLongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6289,10 +5601,6 @@ class MapLongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6313,8 +5621,10 @@ class MapLongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6334,38 +5644,30 @@ class MapLongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6380,10 +5682,6 @@ class MapLongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6404,8 +5702,10 @@ class MapLongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6425,38 +5725,30 @@ class MapLongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6471,10 +5763,6 @@ class MapLongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6495,8 +5783,10 @@ class MapLongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6516,38 +5806,30 @@ class MapLongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6562,10 +5844,6 @@ class MapLongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6586,8 +5864,10 @@ class MapLongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6607,38 +5887,30 @@ class MapLongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6653,10 +5925,6 @@ class MapLongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6677,8 +5945,10 @@ class MapLongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6698,38 +5968,30 @@ class MapLongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6744,10 +6006,6 @@ class MapLongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6768,8 +6026,10 @@ class MapLongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6789,38 +6049,30 @@ class MapLongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6835,10 +6087,6 @@ class MapLongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6859,8 +6107,10 @@ class MapLongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6880,38 +6130,30 @@ class MapLongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6926,10 +6168,6 @@ class MapLongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6950,8 +6188,10 @@ class MapLongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6971,38 +6211,30 @@ class MapLongInnerStructureHelperPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7017,10 +6249,6 @@ class MapLongInnerStructureHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7041,8 +6269,10 @@ class MapLongInnerStructureHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7062,38 +6292,30 @@ class MapLongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7108,10 +6330,6 @@ class MapLongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7132,8 +6350,10 @@ class MapLongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7153,38 +6373,30 @@ class MapULongShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7199,10 +6411,6 @@ class MapULongShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7223,8 +6431,10 @@ class MapULongShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7244,38 +6454,30 @@ class MapULongUShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7290,10 +6492,6 @@ class MapULongUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7314,8 +6512,10 @@ class MapULongUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7335,38 +6535,30 @@ class MapULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7381,10 +6573,6 @@ class MapULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7405,8 +6593,10 @@ class MapULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7426,38 +6616,30 @@ class MapULongULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7472,10 +6654,6 @@ class MapULongULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7496,8 +6674,10 @@ class MapULongULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7517,38 +6697,30 @@ class MapKeyULongValueLongLongPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7563,10 +6735,6 @@ class MapKeyULongValueLongLongPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7587,8 +6755,10 @@ class MapKeyULongValueLongLongPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7608,38 +6778,30 @@ class MapULongULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7654,10 +6816,6 @@ class MapULongULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7678,8 +6836,10 @@ class MapULongULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7699,38 +6859,30 @@ class MapULongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7745,10 +6897,6 @@ class MapULongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7769,8 +6917,10 @@ class MapULongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7790,38 +6940,30 @@ class MapULongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7836,10 +6978,6 @@ class MapULongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7860,8 +6998,10 @@ class MapULongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7881,38 +7021,30 @@ class MapKeyULongValueLongDoublePubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7927,10 +7059,6 @@ class MapKeyULongValueLongDoublePubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7951,8 +7079,10 @@ class MapKeyULongValueLongDoublePubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7972,38 +7102,30 @@ class MapULongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8018,10 +7140,6 @@ class MapULongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8042,8 +7160,10 @@ class MapULongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8063,38 +7183,30 @@ class MapULongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8109,10 +7221,6 @@ class MapULongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8133,8 +7241,10 @@ class MapULongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8154,38 +7264,30 @@ class MapULongCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8200,10 +7302,6 @@ class MapULongCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8224,8 +7322,10 @@ class MapULongCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8245,38 +7345,30 @@ class MapULongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8291,10 +7383,6 @@ class MapULongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8315,8 +7403,10 @@ class MapULongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8336,38 +7426,30 @@ class MapULongStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8382,10 +7464,6 @@ class MapULongStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8406,8 +7484,10 @@ class MapULongStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8427,38 +7507,30 @@ class MapULongWStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8473,10 +7545,6 @@ class MapULongWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8497,8 +7565,10 @@ class MapULongWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8518,38 +7588,30 @@ class MapULongInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8564,10 +7626,6 @@ class MapULongInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8588,8 +7646,10 @@ class MapULongInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8609,38 +7669,30 @@ class MapULongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8655,10 +7707,6 @@ class MapULongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8679,8 +7727,10 @@ class MapULongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8700,38 +7750,30 @@ class MapULongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8746,10 +7788,6 @@ class MapULongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8770,8 +7808,10 @@ class MapULongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8791,38 +7831,30 @@ class MapULongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8837,10 +7869,6 @@ class MapULongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8861,8 +7889,10 @@ class MapULongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8882,38 +7912,30 @@ class MapULongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -8928,10 +7950,6 @@ class MapULongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -8952,8 +7970,10 @@ class MapULongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -8973,38 +7993,30 @@ class MapULongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9019,10 +8031,6 @@ class MapULongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9043,8 +8051,10 @@ class MapULongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9064,38 +8074,30 @@ class MapULongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9110,10 +8112,6 @@ class MapULongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9134,8 +8132,10 @@ class MapULongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9155,38 +8155,30 @@ class MapULongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9201,10 +8193,6 @@ class MapULongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9225,8 +8213,10 @@ class MapULongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9246,38 +8236,30 @@ class MapULongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9292,10 +8274,6 @@ class MapULongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9316,8 +8294,10 @@ class MapULongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9337,38 +8317,30 @@ class MapULongInnerStructureHelperPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9383,10 +8355,6 @@ class MapULongInnerStructureHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9407,8 +8375,10 @@ class MapULongInnerStructureHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9428,38 +8398,30 @@ class MapULongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9474,10 +8436,6 @@ class MapULongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9498,8 +8456,10 @@ class MapULongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9519,38 +8479,30 @@ class MapLongLongShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9565,10 +8517,6 @@ class MapLongLongShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9589,8 +8537,10 @@ class MapLongLongShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9610,38 +8560,30 @@ class MapLongLongUShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9656,10 +8598,6 @@ class MapLongLongUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9680,8 +8618,10 @@ class MapLongLongUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9701,38 +8641,30 @@ class MapLongLongKeyLongValuePubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9747,10 +8679,6 @@ class MapLongLongKeyLongValuePubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9771,8 +8699,10 @@ class MapLongLongKeyLongValuePubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9792,38 +8722,30 @@ class MapLongLongULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9838,10 +8760,6 @@ class MapLongLongULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9862,8 +8780,10 @@ class MapLongLongULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9883,38 +8803,30 @@ class MapLongLongLongLongPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -9929,10 +8841,6 @@ class MapLongLongLongLongPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -9953,8 +8861,10 @@ class MapLongLongLongLongPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -9974,38 +8884,30 @@ class MapLongLongULongLongPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10020,10 +8922,6 @@ class MapLongLongULongLongPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10044,8 +8942,10 @@ class MapLongLongULongLongPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10065,38 +8965,30 @@ class MapLongLongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10111,10 +9003,6 @@ class MapLongLongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10135,8 +9023,10 @@ class MapLongLongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10156,38 +9046,30 @@ class MapLongLongKeyDoubleValuePubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10202,10 +9084,6 @@ class MapLongLongKeyDoubleValuePubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10226,8 +9104,10 @@ class MapLongLongKeyDoubleValuePubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10247,38 +9127,30 @@ class MapLongLongLongDoublePubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10293,10 +9165,6 @@ class MapLongLongLongDoublePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10317,8 +9185,10 @@ class MapLongLongLongDoublePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10338,38 +9208,30 @@ class MapLongLongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10384,10 +9246,6 @@ class MapLongLongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10408,8 +9266,10 @@ class MapLongLongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10429,38 +9289,30 @@ class MapLongLongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10475,10 +9327,6 @@ class MapLongLongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10499,8 +9347,10 @@ class MapLongLongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10520,38 +9370,30 @@ class MapLongLongCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10566,10 +9408,6 @@ class MapLongLongCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10590,8 +9428,10 @@ class MapLongLongCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10611,38 +9451,30 @@ class MapLongLongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10657,10 +9489,6 @@ class MapLongLongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10681,8 +9509,10 @@ class MapLongLongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10702,38 +9532,30 @@ class MapLongLongStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10748,10 +9570,6 @@ class MapLongLongStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10772,8 +9590,10 @@ class MapLongLongStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10793,38 +9613,30 @@ class MapLongLongWStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10839,10 +9651,6 @@ class MapLongLongWStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10863,8 +9671,10 @@ class MapLongLongWStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10884,38 +9694,30 @@ class MapLongLongInnerAliasBoundedStringHelperPubSubType : public eprosima::fast eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -10930,10 +9732,6 @@ class MapLongLongInnerAliasBoundedStringHelperPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -10954,8 +9752,10 @@ class MapLongLongInnerAliasBoundedStringHelperPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -10975,38 +9775,30 @@ class MapLongLongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fas eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11021,10 +9813,6 @@ class MapLongLongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11045,8 +9833,10 @@ class MapLongLongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11066,38 +9856,30 @@ class MapLongLongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11112,10 +9894,6 @@ class MapLongLongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11136,8 +9914,10 @@ class MapLongLongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11157,38 +9937,30 @@ class MapLongLongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11203,10 +9975,6 @@ class MapLongLongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11227,8 +9995,10 @@ class MapLongLongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11248,38 +10018,30 @@ class MapLongLongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11294,10 +10056,6 @@ class MapLongLongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11318,8 +10076,10 @@ class MapLongLongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11339,38 +10099,30 @@ class MapLongLongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11385,10 +10137,6 @@ class MapLongLongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11409,8 +10157,10 @@ class MapLongLongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11430,38 +10180,30 @@ class MapLongLongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11476,10 +10218,6 @@ class MapLongLongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11500,8 +10238,10 @@ class MapLongLongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11521,38 +10261,30 @@ class MapLongLongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11567,10 +10299,6 @@ class MapLongLongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11591,8 +10319,10 @@ class MapLongLongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11612,38 +10342,30 @@ class MapLongLongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11658,10 +10380,6 @@ class MapLongLongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11682,8 +10400,10 @@ class MapLongLongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11703,38 +10423,30 @@ class MapLongLongInnerStructureHelperPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11749,10 +10461,6 @@ class MapLongLongInnerStructureHelperPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11773,8 +10481,10 @@ class MapLongLongInnerStructureHelperPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11794,38 +10504,30 @@ class MapLongLongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11840,10 +10542,6 @@ class MapLongLongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11864,8 +10562,10 @@ class MapLongLongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11885,38 +10585,30 @@ class MapULongLongShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -11931,10 +10623,6 @@ class MapULongLongShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -11955,8 +10643,10 @@ class MapULongLongShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -11976,38 +10666,30 @@ class MapULongLongUShortPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12022,10 +10704,6 @@ class MapULongLongUShortPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12046,8 +10724,10 @@ class MapULongLongUShortPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12067,38 +10747,30 @@ class MapULongLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12113,10 +10785,6 @@ class MapULongLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12137,8 +10805,10 @@ class MapULongLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12158,38 +10828,30 @@ class MapULongLongULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12204,10 +10866,6 @@ class MapULongLongULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12228,8 +10886,10 @@ class MapULongLongULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12249,38 +10909,30 @@ class MapULongLongLongLongPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12295,10 +10947,6 @@ class MapULongLongLongLongPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12319,8 +10967,10 @@ class MapULongLongLongLongPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12340,38 +10990,30 @@ class MapULongLongULongLongPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12386,10 +11028,6 @@ class MapULongLongULongLongPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12410,8 +11048,10 @@ class MapULongLongULongLongPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12431,38 +11071,30 @@ class MapULongLongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12477,10 +11109,6 @@ class MapULongLongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12501,8 +11129,10 @@ class MapULongLongFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12522,38 +11152,30 @@ class MapKeyULongLongValueDoublePubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12568,10 +11190,6 @@ class MapKeyULongLongValueDoublePubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12592,8 +11210,10 @@ class MapKeyULongLongValueDoublePubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12613,38 +11233,30 @@ class MapULongLongLongDoublePubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12659,10 +11271,6 @@ class MapULongLongLongDoublePubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12683,8 +11291,10 @@ class MapULongLongLongDoublePubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12704,38 +11314,30 @@ class MapULongLongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12750,10 +11352,6 @@ class MapULongLongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12774,8 +11372,10 @@ class MapULongLongBooleanPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12795,38 +11395,30 @@ class MapULongLongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12841,10 +11433,6 @@ class MapULongLongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12865,8 +11453,10 @@ class MapULongLongOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12886,38 +11476,30 @@ class MapULongLongCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -12932,10 +11514,6 @@ class MapULongLongCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -12956,8 +11534,10 @@ class MapULongLongCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -12977,38 +11557,30 @@ class MapULongLongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13023,10 +11595,6 @@ class MapULongLongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13047,8 +11615,10 @@ class MapULongLongWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13068,38 +11638,30 @@ class MapULongLongStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13114,10 +11676,6 @@ class MapULongLongStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13138,8 +11696,10 @@ class MapULongLongStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13159,38 +11719,30 @@ class MapULongLongWStringPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13205,10 +11757,6 @@ class MapULongLongWStringPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13229,8 +11777,10 @@ class MapULongLongWStringPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13250,38 +11800,30 @@ class MapULongLongInnerAliasBoundedStringHelperPubSubType : public eprosima::fas eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13296,10 +11838,6 @@ class MapULongLongInnerAliasBoundedStringHelperPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13320,8 +11858,10 @@ class MapULongLongInnerAliasBoundedStringHelperPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13341,38 +11881,30 @@ class MapULongLongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13387,10 +11919,6 @@ class MapULongLongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13411,8 +11939,10 @@ class MapULongLongInnerAliasBoundedWStringHelperPubSubType : public eprosima::fa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13432,38 +11962,30 @@ class MapULongLongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13478,10 +12000,6 @@ class MapULongLongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13502,8 +12020,10 @@ class MapULongLongInnerEnumHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13523,38 +12043,30 @@ class MapULongLongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13569,10 +12081,6 @@ class MapULongLongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13593,8 +12101,10 @@ class MapULongLongInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13614,38 +12124,30 @@ class MapULongLongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13660,10 +12162,6 @@ class MapULongLongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13684,8 +12182,10 @@ class MapULongLongInnerAliasHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13705,38 +12205,30 @@ class MapULongLongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13751,10 +12243,6 @@ class MapULongLongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13775,8 +12263,10 @@ class MapULongLongInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13796,38 +12286,30 @@ class MapULongLongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13842,10 +12324,6 @@ class MapULongLongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13866,8 +12344,10 @@ class MapULongLongInnerAliasSequenceHelperPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13887,38 +12367,30 @@ class MapULongLongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -13933,10 +12405,6 @@ class MapULongLongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -13957,8 +12425,10 @@ class MapULongLongInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -13978,38 +12448,30 @@ class MapULongLongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14024,10 +12486,6 @@ class MapULongLongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14048,8 +12506,10 @@ class MapULongLongInnerUnionHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14069,38 +12529,30 @@ class MapULongLongInnerStructureHelperPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14115,10 +12567,6 @@ class MapULongLongInnerStructureHelperPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14139,8 +12587,10 @@ class MapULongLongInnerStructureHelperPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14160,38 +12610,30 @@ class MapULongLongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14206,10 +12648,6 @@ class MapULongLongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14230,8 +12668,10 @@ class MapULongLongInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14251,38 +12691,30 @@ class MapStringShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14297,10 +12729,6 @@ class MapStringShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14321,8 +12749,10 @@ class MapStringShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14342,38 +12772,30 @@ class MapStringUShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14388,10 +12810,6 @@ class MapStringUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14412,8 +12830,10 @@ class MapStringUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14433,38 +12853,30 @@ class MapStringLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14479,10 +12891,6 @@ class MapStringLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14503,8 +12911,10 @@ class MapStringLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14524,38 +12934,30 @@ class MapStringULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14570,10 +12972,6 @@ class MapStringULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14594,8 +12992,10 @@ class MapStringULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14615,38 +13015,30 @@ class MapStringLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14661,10 +13053,6 @@ class MapStringLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14685,8 +13073,10 @@ class MapStringLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14706,38 +13096,30 @@ class MapStringULongLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14752,10 +13134,6 @@ class MapStringULongLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14776,8 +13154,10 @@ class MapStringULongLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14797,38 +13177,30 @@ class MapStringFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14843,10 +13215,6 @@ class MapStringFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14867,8 +13235,10 @@ class MapStringFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14888,38 +13258,30 @@ class MapStringDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -14934,10 +13296,6 @@ class MapStringDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -14958,8 +13316,10 @@ class MapStringDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -14979,38 +13339,30 @@ class MapStringLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15025,10 +13377,6 @@ class MapStringLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15049,8 +13397,10 @@ class MapStringLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15070,38 +13420,30 @@ class MapStringBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15116,10 +13458,6 @@ class MapStringBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15140,8 +13478,10 @@ class MapStringBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15161,38 +13501,30 @@ class MapStringOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15207,10 +13539,6 @@ class MapStringOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15231,8 +13559,10 @@ class MapStringOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15252,38 +13582,30 @@ class MapStringCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15298,10 +13620,6 @@ class MapStringCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15322,8 +13640,10 @@ class MapStringCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15343,38 +13663,30 @@ class MapStringWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15389,10 +13701,6 @@ class MapStringWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15413,8 +13721,10 @@ class MapStringWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15434,38 +13744,30 @@ class MapStringStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15480,10 +13782,6 @@ class MapStringStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15504,8 +13802,10 @@ class MapStringStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15525,38 +13825,30 @@ class MapStringWStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15571,10 +13863,6 @@ class MapStringWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15595,8 +13883,10 @@ class MapStringWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15616,38 +13906,30 @@ class MapStringInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15662,10 +13944,6 @@ class MapStringInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15686,8 +13964,10 @@ class MapStringInnerAliasBoundedStringHelperPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15707,38 +13987,30 @@ class MapStringInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15753,10 +14025,6 @@ class MapStringInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15777,8 +14045,10 @@ class MapStringInnerAliasBoundedWStringHelperPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15798,38 +14068,30 @@ class MapStringInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15844,10 +14106,6 @@ class MapStringInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15868,8 +14126,10 @@ class MapStringInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15889,38 +14149,30 @@ class MapStringInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -15935,10 +14187,6 @@ class MapStringInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -15959,8 +14207,10 @@ class MapStringInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -15980,38 +14230,30 @@ class MapStringInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16026,10 +14268,6 @@ class MapStringInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16050,8 +14288,10 @@ class MapStringInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16071,38 +14311,30 @@ class MapStringInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16117,10 +14349,6 @@ class MapStringInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16141,8 +14369,10 @@ class MapStringInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16162,38 +14392,30 @@ class MapStringInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16208,10 +14430,6 @@ class MapStringInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16232,8 +14450,10 @@ class MapStringInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16253,38 +14473,30 @@ class MapStringInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16299,10 +14511,6 @@ class MapStringInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16323,8 +14531,10 @@ class MapStringInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16344,38 +14554,30 @@ class MapStringInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16390,10 +14592,6 @@ class MapStringInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16414,8 +14612,10 @@ class MapStringInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16435,38 +14635,30 @@ class MapStringInnerStructureHelperPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16481,10 +14673,6 @@ class MapStringInnerStructureHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16505,8 +14693,10 @@ class MapStringInnerStructureHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16526,38 +14716,30 @@ class MapStringInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16572,10 +14754,6 @@ class MapStringInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16596,8 +14774,10 @@ class MapStringInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16617,38 +14797,30 @@ class MapWStringShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16663,10 +14835,6 @@ class MapWStringShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16687,8 +14855,10 @@ class MapWStringShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16708,38 +14878,30 @@ class MapWStringUShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16754,10 +14916,6 @@ class MapWStringUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16778,8 +14936,10 @@ class MapWStringUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16799,38 +14959,30 @@ class MapWStringLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16845,10 +14997,6 @@ class MapWStringLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16869,8 +15017,10 @@ class MapWStringLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16890,38 +15040,30 @@ class MapWStringULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -16936,10 +15078,6 @@ class MapWStringULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -16960,8 +15098,10 @@ class MapWStringULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -16981,38 +15121,30 @@ class MapWStringLongLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17027,10 +15159,6 @@ class MapWStringLongLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17051,8 +15179,10 @@ class MapWStringLongLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17072,38 +15202,30 @@ class MapWStringULongLongPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17118,10 +15240,6 @@ class MapWStringULongLongPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17142,8 +15260,10 @@ class MapWStringULongLongPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17163,38 +15283,30 @@ class MapWStringFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17209,10 +15321,6 @@ class MapWStringFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17233,8 +15341,10 @@ class MapWStringFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17254,38 +15364,30 @@ class MapWStringDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17300,10 +15402,6 @@ class MapWStringDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17324,8 +15422,10 @@ class MapWStringDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17345,38 +15445,30 @@ class MapWStringLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17391,10 +15483,6 @@ class MapWStringLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17415,8 +15503,10 @@ class MapWStringLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17436,38 +15526,30 @@ class MapWStringBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17482,10 +15564,6 @@ class MapWStringBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17506,8 +15584,10 @@ class MapWStringBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17527,38 +15607,30 @@ class MapWStringOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17573,10 +15645,6 @@ class MapWStringOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17597,8 +15665,10 @@ class MapWStringOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17618,38 +15688,30 @@ class MapWStringCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17664,10 +15726,6 @@ class MapWStringCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17688,8 +15746,10 @@ class MapWStringCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17709,38 +15769,30 @@ class MapWStringWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17755,10 +15807,6 @@ class MapWStringWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17779,8 +15827,10 @@ class MapWStringWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17800,38 +15850,30 @@ class MapWStringStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17846,10 +15888,6 @@ class MapWStringStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17870,8 +15908,10 @@ class MapWStringStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17891,38 +15931,30 @@ class MapWStringWStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -17937,10 +15969,6 @@ class MapWStringWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -17961,8 +15989,10 @@ class MapWStringWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -17982,38 +16012,30 @@ class MapWStringInnerAliasBoundedStringHelperPubSubType : public eprosima::fastd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18028,10 +16050,6 @@ class MapWStringInnerAliasBoundedStringHelperPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18052,8 +16070,10 @@ class MapWStringInnerAliasBoundedStringHelperPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18073,38 +16093,30 @@ class MapWStringInnerAliasBoundedWStringHelperPubSubType : public eprosima::fast eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18119,10 +16131,6 @@ class MapWStringInnerAliasBoundedWStringHelperPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18143,8 +16151,10 @@ class MapWStringInnerAliasBoundedWStringHelperPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18164,38 +16174,30 @@ class MapWStringInnerEnumHelperPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18210,10 +16212,6 @@ class MapWStringInnerEnumHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18234,8 +16232,10 @@ class MapWStringInnerEnumHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18255,38 +16255,30 @@ class MapWStringInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18301,10 +16293,6 @@ class MapWStringInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18325,8 +16313,10 @@ class MapWStringInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18346,38 +16336,30 @@ class MapWStringInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18392,10 +16374,6 @@ class MapWStringInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18416,8 +16394,10 @@ class MapWStringInnerAliasHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18437,38 +16417,30 @@ class MapWStringInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18483,10 +16455,6 @@ class MapWStringInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18507,8 +16475,10 @@ class MapWStringInnerAliasArrayHelperPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18528,38 +16498,30 @@ class MapWStringInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::d eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18574,10 +16536,6 @@ class MapWStringInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18598,8 +16556,10 @@ class MapWStringInnerAliasSequenceHelperPubSubType : public eprosima::fastdds::d #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18619,38 +16579,30 @@ class MapWStringInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18665,10 +16617,6 @@ class MapWStringInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18689,8 +16637,10 @@ class MapWStringInnerAliasMapHelperPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18710,38 +16660,30 @@ class MapWStringInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18756,10 +16698,6 @@ class MapWStringInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18780,8 +16718,10 @@ class MapWStringInnerUnionHelperPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18801,38 +16741,30 @@ class MapWStringInnerStructureHelperPubSubType : public eprosima::fastdds::dds:: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18847,10 +16779,6 @@ class MapWStringInnerStructureHelperPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18871,8 +16799,10 @@ class MapWStringInnerStructureHelperPubSubType : public eprosima::fastdds::dds:: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18892,38 +16822,30 @@ class MapWStringInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -18938,10 +16860,6 @@ class MapWStringInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -18962,8 +16880,10 @@ class MapWStringInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -18983,38 +16903,30 @@ class MapInnerAliasBoundedStringHelperShortPubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19029,10 +16941,6 @@ class MapInnerAliasBoundedStringHelperShortPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19053,8 +16961,10 @@ class MapInnerAliasBoundedStringHelperShortPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19074,38 +16984,30 @@ class MapInnerAliasBoundedStringHelperUShortPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19120,10 +17022,6 @@ class MapInnerAliasBoundedStringHelperUShortPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19144,8 +17042,10 @@ class MapInnerAliasBoundedStringHelperUShortPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19165,38 +17065,30 @@ class MapInnerAliasBoundedStringHelperLongPubSubType : public eprosima::fastdds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19211,10 +17103,6 @@ class MapInnerAliasBoundedStringHelperLongPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19235,8 +17123,10 @@ class MapInnerAliasBoundedStringHelperLongPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19256,38 +17146,30 @@ class MapInnerAliasBoundedStringHelperULongPubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19302,10 +17184,6 @@ class MapInnerAliasBoundedStringHelperULongPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19326,8 +17204,10 @@ class MapInnerAliasBoundedStringHelperULongPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19347,38 +17227,30 @@ class MapInnerAliasBoundedStringHelperLongLongPubSubType : public eprosima::fast eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19393,10 +17265,6 @@ class MapInnerAliasBoundedStringHelperLongLongPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19417,8 +17285,10 @@ class MapInnerAliasBoundedStringHelperLongLongPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19438,38 +17308,30 @@ class MapInnerAliasBoundedStringHelperULongLongPubSubType : public eprosima::fas eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19484,10 +17346,6 @@ class MapInnerAliasBoundedStringHelperULongLongPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19508,8 +17366,10 @@ class MapInnerAliasBoundedStringHelperULongLongPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19529,38 +17389,30 @@ class MapInnerAliasBoundedStringHelperFloatPubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19575,10 +17427,6 @@ class MapInnerAliasBoundedStringHelperFloatPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19599,8 +17447,10 @@ class MapInnerAliasBoundedStringHelperFloatPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19620,38 +17470,30 @@ class MapInnerAliasBoundedStringHelperDoublePubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19666,10 +17508,6 @@ class MapInnerAliasBoundedStringHelperDoublePubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19690,8 +17528,10 @@ class MapInnerAliasBoundedStringHelperDoublePubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19711,38 +17551,30 @@ class MapInnerAliasBoundedStringHelperLongDoublePubSubType : public eprosima::fa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19757,10 +17589,6 @@ class MapInnerAliasBoundedStringHelperLongDoublePubSubType : public eprosima::fa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19781,8 +17609,10 @@ class MapInnerAliasBoundedStringHelperLongDoublePubSubType : public eprosima::fa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19802,38 +17632,30 @@ class MapInnerAliasBoundedStringHelperBooleanPubSubType : public eprosima::fastd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19848,10 +17670,6 @@ class MapInnerAliasBoundedStringHelperBooleanPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19872,8 +17690,10 @@ class MapInnerAliasBoundedStringHelperBooleanPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19893,38 +17713,30 @@ class MapInnerAliasBoundedStringHelperOctetPubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -19939,10 +17751,6 @@ class MapInnerAliasBoundedStringHelperOctetPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -19963,8 +17771,10 @@ class MapInnerAliasBoundedStringHelperOctetPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -19984,38 +17794,30 @@ class MapInnerAliasBoundedStringHelperCharPubSubType : public eprosima::fastdds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20030,10 +17832,6 @@ class MapInnerAliasBoundedStringHelperCharPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20054,8 +17852,10 @@ class MapInnerAliasBoundedStringHelperCharPubSubType : public eprosima::fastdds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20075,38 +17875,30 @@ class MapInnerAliasBoundedStringHelperWCharPubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20121,10 +17913,6 @@ class MapInnerAliasBoundedStringHelperWCharPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20145,8 +17933,10 @@ class MapInnerAliasBoundedStringHelperWCharPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20166,38 +17956,30 @@ class MapInnerAliasBoundedStringHelperStringPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20212,10 +17994,6 @@ class MapInnerAliasBoundedStringHelperStringPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20236,8 +18014,10 @@ class MapInnerAliasBoundedStringHelperStringPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20257,38 +18037,30 @@ class MapInnerAliasBoundedStringHelperWStringPubSubType : public eprosima::fastd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20303,10 +18075,6 @@ class MapInnerAliasBoundedStringHelperWStringPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20327,8 +18095,10 @@ class MapInnerAliasBoundedStringHelperWStringPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20348,38 +18118,30 @@ class MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType : eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20394,10 +18156,6 @@ class MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType : #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20418,8 +18176,10 @@ class MapInnerAliasBoundedStringHelperInnerAliasBoundedStringHelperPubSubType : #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20439,38 +18199,30 @@ class MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType : eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20485,10 +18237,6 @@ class MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType : #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20509,8 +18257,10 @@ class MapInnerAliasBoundedStringHelperInnerAliasBoundedWStringHelperPubSubType : #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20530,38 +18280,30 @@ class MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType : public eprosim eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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 std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport bool deserialize( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20576,10 +18318,6 @@ class MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType : public eprosim #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20600,8 +18338,10 @@ class MapInnerAliasBoundedStringHelperInnerEnumHelperPubSubType : public eprosim #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20621,38 +18361,30 @@ class MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType : public epro eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20667,10 +18399,6 @@ class MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType : public epro #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20691,8 +18419,10 @@ class MapInnerAliasBoundedStringHelperInnerBitMaskHelperPubSubType : public epro #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20712,38 +18442,30 @@ class MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType : public eprosi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20758,10 +18480,6 @@ class MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType : public eprosi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20782,8 +18500,10 @@ class MapInnerAliasBoundedStringHelperInnerAliasHelperPubSubType : public eprosi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20803,38 +18523,30 @@ class MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType : public e eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20849,10 +18561,6 @@ class MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType : public e #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20873,8 +18581,10 @@ class MapInnerAliasBoundedStringHelperInnerAliasArrayHelperPubSubType : public e #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20894,38 +18604,30 @@ class MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType : publi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -20940,10 +18642,6 @@ class MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType : publi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -20964,8 +18662,10 @@ class MapInnerAliasBoundedStringHelperInnerAliasSequenceHelperPubSubType : publi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -20985,38 +18685,30 @@ class MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType : public epr eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21031,10 +18723,6 @@ class MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType : public epr #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21055,8 +18743,10 @@ class MapInnerAliasBoundedStringHelperInnerAliasMapHelperPubSubType : public epr #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21076,38 +18766,30 @@ class MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType : public eprosi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21122,10 +18804,6 @@ class MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType : public eprosi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21146,8 +18824,10 @@ class MapInnerAliasBoundedStringHelperInnerUnionHelperPubSubType : public eprosi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21167,38 +18847,30 @@ class MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType : public ep eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21213,10 +18885,6 @@ class MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType : public ep #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21237,8 +18905,10 @@ class MapInnerAliasBoundedStringHelperInnerStructureHelperPubSubType : public ep #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21258,38 +18928,30 @@ class MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType : public epros eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21304,10 +18966,6 @@ class MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType : public epros #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21328,8 +18986,10 @@ class MapInnerAliasBoundedStringHelperInnerBitsetHelperPubSubType : public epros #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21349,38 +19009,30 @@ class MapInnerAliasBoundedWStringHelperShortPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21395,10 +19047,6 @@ class MapInnerAliasBoundedWStringHelperShortPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21419,8 +19067,10 @@ class MapInnerAliasBoundedWStringHelperShortPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21440,38 +19090,30 @@ class MapInnerAliasBoundedWStringHelperUShortPubSubType : public eprosima::fastd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21486,10 +19128,6 @@ class MapInnerAliasBoundedWStringHelperUShortPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21510,8 +19148,10 @@ class MapInnerAliasBoundedWStringHelperUShortPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21531,38 +19171,30 @@ class MapInnerAliasBoundedWStringHelperLongPubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21577,10 +19209,6 @@ class MapInnerAliasBoundedWStringHelperLongPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21601,8 +19229,10 @@ class MapInnerAliasBoundedWStringHelperLongPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21622,38 +19252,30 @@ class MapInnerAliasBoundedWStringHelperULongPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21668,10 +19290,6 @@ class MapInnerAliasBoundedWStringHelperULongPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21692,8 +19310,10 @@ class MapInnerAliasBoundedWStringHelperULongPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21713,38 +19333,30 @@ class MapInnerAliasBoundedWStringHelperLongLongPubSubType : public eprosima::fas eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21759,10 +19371,6 @@ class MapInnerAliasBoundedWStringHelperLongLongPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21783,8 +19391,10 @@ class MapInnerAliasBoundedWStringHelperLongLongPubSubType : public eprosima::fas #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21804,38 +19414,30 @@ class MapInnerAliasBoundedWStringHelperULongLongPubSubType : public eprosima::fa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21850,10 +19452,6 @@ class MapInnerAliasBoundedWStringHelperULongLongPubSubType : public eprosima::fa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21874,8 +19472,10 @@ class MapInnerAliasBoundedWStringHelperULongLongPubSubType : public eprosima::fa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21895,38 +19495,30 @@ class MapInnerAliasBoundedWStringHelperFloatPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -21941,10 +19533,6 @@ class MapInnerAliasBoundedWStringHelperFloatPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -21965,8 +19553,10 @@ class MapInnerAliasBoundedWStringHelperFloatPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -21986,38 +19576,30 @@ class MapInnerAliasBoundedWStringHelperDoublePubSubType : public eprosima::fastd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22032,10 +19614,6 @@ class MapInnerAliasBoundedWStringHelperDoublePubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22056,8 +19634,10 @@ class MapInnerAliasBoundedWStringHelperDoublePubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22077,38 +19657,30 @@ class MapInnerAliasBoundedWStringHelperLongDoublePubSubType : public eprosima::f eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22123,10 +19695,6 @@ class MapInnerAliasBoundedWStringHelperLongDoublePubSubType : public eprosima::f #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22147,8 +19715,10 @@ class MapInnerAliasBoundedWStringHelperLongDoublePubSubType : public eprosima::f #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22168,38 +19738,30 @@ class MapInnerAliasBoundedWStringHelperBooleanPubSubType : public eprosima::fast eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22214,10 +19776,6 @@ class MapInnerAliasBoundedWStringHelperBooleanPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22238,8 +19796,10 @@ class MapInnerAliasBoundedWStringHelperBooleanPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22259,38 +19819,30 @@ class MapInnerAliasBoundedWStringHelperOctetPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22305,10 +19857,6 @@ class MapInnerAliasBoundedWStringHelperOctetPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22329,8 +19877,10 @@ class MapInnerAliasBoundedWStringHelperOctetPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22350,38 +19900,30 @@ class MapInnerAliasBoundedWStringHelperCharPubSubType : public eprosima::fastdds eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22396,10 +19938,6 @@ class MapInnerAliasBoundedWStringHelperCharPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22420,8 +19958,10 @@ class MapInnerAliasBoundedWStringHelperCharPubSubType : public eprosima::fastdds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22441,38 +19981,30 @@ class MapInnerAliasBoundedWStringHelperWCharPubSubType : public eprosima::fastdd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22487,10 +20019,6 @@ class MapInnerAliasBoundedWStringHelperWCharPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22511,8 +20039,10 @@ class MapInnerAliasBoundedWStringHelperWCharPubSubType : public eprosima::fastdd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22532,38 +20062,30 @@ class MapInnerAliasBoundedWStringHelperStringPubSubType : public eprosima::fastd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22578,10 +20100,6 @@ class MapInnerAliasBoundedWStringHelperStringPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22602,8 +20120,10 @@ class MapInnerAliasBoundedWStringHelperStringPubSubType : public eprosima::fastd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22623,38 +20143,30 @@ class MapInnerAliasBoundedWStringHelperWStringPubSubType : public eprosima::fast eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22669,10 +20181,6 @@ class MapInnerAliasBoundedWStringHelperWStringPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22693,8 +20201,10 @@ class MapInnerAliasBoundedWStringHelperWStringPubSubType : public eprosima::fast #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22714,38 +20224,30 @@ class MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType : eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22760,10 +20262,6 @@ class MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType : #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22784,8 +20282,10 @@ class MapInnerAliasBoundedWStringHelperInnerAliasBoundedStringHelperPubSubType : #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22805,38 +20305,30 @@ class MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22851,10 +20343,6 @@ class MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22875,8 +20363,10 @@ class MapInnerAliasBoundedWStringHelperInnerAliasBoundedWStringHelperPubSubType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22896,38 +20386,30 @@ class MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType : public eprosi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -22942,10 +20424,6 @@ class MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType : public eprosi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -22966,8 +20444,10 @@ class MapInnerAliasBoundedWStringHelperInnerEnumHelperPubSubType : public eprosi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -22987,38 +20467,30 @@ class MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType : public epr eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -23033,10 +20505,6 @@ class MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType : public epr #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -23057,8 +20525,10 @@ class MapInnerAliasBoundedWStringHelperInnerBitMaskHelperPubSubType : public epr #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -23078,38 +20548,30 @@ class MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType : public epros eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -23124,10 +20586,6 @@ class MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType : public epros #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -23148,8 +20606,10 @@ class MapInnerAliasBoundedWStringHelperInnerAliasHelperPubSubType : public epros #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -23169,38 +20629,30 @@ class MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType : public eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -23215,10 +20667,6 @@ class MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType : public #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -23239,8 +20687,10 @@ class MapInnerAliasBoundedWStringHelperInnerAliasArrayHelperPubSubType : public #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -23260,38 +20710,30 @@ class MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType : publ eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -23306,10 +20748,6 @@ class MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType : publ #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -23330,8 +20768,10 @@ class MapInnerAliasBoundedWStringHelperInnerAliasSequenceHelperPubSubType : publ #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -23351,38 +20791,30 @@ class MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType : public ep eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -23397,10 +20829,6 @@ class MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType : public ep #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -23421,8 +20849,10 @@ class MapInnerAliasBoundedWStringHelperInnerAliasMapHelperPubSubType : public ep #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -23442,38 +20872,30 @@ class MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType : public epros eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -23488,10 +20910,6 @@ class MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType : public epros #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -23512,8 +20930,10 @@ class MapInnerAliasBoundedWStringHelperInnerUnionHelperPubSubType : public epros #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -23533,38 +20953,30 @@ class MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType : public e eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -23579,10 +20991,6 @@ class MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType : public e #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -23603,8 +21011,10 @@ class MapInnerAliasBoundedWStringHelperInnerStructureHelperPubSubType : public e #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -23624,38 +21034,30 @@ class MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType : public epro eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -23670,10 +21072,6 @@ class MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType : public epro #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -23694,8 +21092,10 @@ class MapInnerAliasBoundedWStringHelperInnerBitsetHelperPubSubType : public epro #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -23715,38 +21115,30 @@ class BoundedSmallMapPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -23761,10 +21153,6 @@ class BoundedSmallMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -23785,8 +21173,10 @@ class BoundedSmallMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -23806,38 +21196,30 @@ class BoundedLargeMapPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -23852,10 +21234,6 @@ class BoundedLargeMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -23876,8 +21254,10 @@ class BoundedLargeMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/member_idPubSubTypes.cxx b/test/dds-types-test/member_idPubSubTypes.cxx index 043b5dd6cc1..805d3efb280 100644 --- a/test/dds-types-test/member_idPubSubTypes.cxx +++ b/test/dds-types-test/member_idPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; FixIdPubSubType::FixIdPubSubType() { - setName("FixId"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FixId::getMaxCdrSerializedSize()); -#else - FixId_max_cdr_typesize; -#endif + set_name("FixId"); + uint32_t type_size = FixId_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FixId_max_key_cdr_typesize > 16 ? FixId_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FixId_max_key_cdr_typesize > 16 ? FixId_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FixIdPubSubType::~FixIdPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FixIdPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FixId* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool FixIdPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FixIdPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool FixIdPubSubType::deserialize( FixId* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool FixIdPubSubType::deserialize( return true; } -std::function FixIdPubSubType::getSerializedSizeProvider( +uint32_t FixIdPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FixIdPubSubType::createData() + 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* FixIdPubSubType::create_data() { return reinterpret_cast(new FixId()); } -void FixIdPubSubType::deleteData( +void FixIdPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FixIdPubSubType::getKey( +bool FixIdPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FixId data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FixIdPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool FixIdPubSubType::getKey( const FixId* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FixId_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FixId_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void FixIdPubSubType::register_type_object_representation() FixHexIdPubSubType::FixHexIdPubSubType() { - setName("FixHexId"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FixHexId::getMaxCdrSerializedSize()); -#else - FixHexId_max_cdr_typesize; -#endif + set_name("FixHexId"); + uint32_t type_size = FixHexId_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FixHexId_max_key_cdr_typesize > 16 ? FixHexId_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FixHexId_max_key_cdr_typesize > 16 ? FixHexId_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FixHexIdPubSubType::~FixHexIdPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FixHexIdPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FixHexId* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool FixHexIdPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FixHexIdPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool FixHexIdPubSubType::deserialize( FixHexId* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool FixHexIdPubSubType::deserialize( return true; } -std::function FixHexIdPubSubType::getSerializedSizeProvider( +uint32_t FixHexIdPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FixHexIdPubSubType::createData() + 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* FixHexIdPubSubType::create_data() { return reinterpret_cast(new FixHexId()); } -void FixHexIdPubSubType::deleteData( +void FixHexIdPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FixHexIdPubSubType::getKey( +bool FixHexIdPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FixHexId data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FixHexIdPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool FixHexIdPubSubType::getKey( const FixHexId* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FixHexId_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FixHexId_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void FixHexIdPubSubType::register_type_object_representation() FixHashidDefaultPubSubType::FixHashidDefaultPubSubType() { - setName("FixHashidDefault"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FixHashidDefault::getMaxCdrSerializedSize()); -#else - FixHashidDefault_max_cdr_typesize; -#endif + set_name("FixHashidDefault"); + uint32_t type_size = FixHashidDefault_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FixHashidDefault_max_key_cdr_typesize > 16 ? FixHashidDefault_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FixHashidDefault_max_key_cdr_typesize > 16 ? FixHashidDefault_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FixHashidDefaultPubSubType::~FixHashidDefaultPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FixHashidDefaultPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FixHashidDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool FixHashidDefaultPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FixHashidDefaultPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool FixHashidDefaultPubSubType::deserialize( FixHashidDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool FixHashidDefaultPubSubType::deserialize( return true; } -std::function FixHashidDefaultPubSubType::getSerializedSizeProvider( +uint32_t FixHashidDefaultPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FixHashidDefaultPubSubType::createData() + 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* FixHashidDefaultPubSubType::create_data() { return reinterpret_cast(new FixHashidDefault()); } -void FixHashidDefaultPubSubType::deleteData( +void FixHashidDefaultPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FixHashidDefaultPubSubType::getKey( +bool FixHashidDefaultPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FixHashidDefault data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FixHashidDefaultPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool FixHashidDefaultPubSubType::getKey( const FixHashidDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FixHashidDefault_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FixHashidDefault_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void FixHashidDefaultPubSubType::register_type_object_representation() FixHashidPubSubType::FixHashidPubSubType() { - setName("FixHashid"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FixHashid::getMaxCdrSerializedSize()); -#else - FixHashid_max_cdr_typesize; -#endif + set_name("FixHashid"); + uint32_t type_size = FixHashid_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FixHashid_max_key_cdr_typesize > 16 ? FixHashid_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FixHashid_max_key_cdr_typesize > 16 ? FixHashid_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FixHashidPubSubType::~FixHashidPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FixHashidPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FixHashid* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool FixHashidPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FixHashidPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool FixHashidPubSubType::deserialize( FixHashid* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool FixHashidPubSubType::deserialize( return true; } -std::function FixHashidPubSubType::getSerializedSizeProvider( +uint32_t FixHashidPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FixHashidPubSubType::createData() + 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* FixHashidPubSubType::create_data() { return reinterpret_cast(new FixHashid()); } -void FixHashidPubSubType::deleteData( +void FixHashidPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FixHashidPubSubType::getKey( +bool FixHashidPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FixHashid data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FixHashidPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool FixHashidPubSubType::getKey( const FixHashid* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FixHashid_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FixHashid_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void FixHashidPubSubType::register_type_object_representation() FixMixPubSubType::FixMixPubSubType() { - setName("FixMix"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FixMix::getMaxCdrSerializedSize()); -#else - FixMix_max_cdr_typesize; -#endif + set_name("FixMix"); + uint32_t type_size = FixMix_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FixMix_max_key_cdr_typesize > 16 ? FixMix_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FixMix_max_key_cdr_typesize > 16 ? FixMix_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FixMixPubSubType::~FixMixPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FixMixPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FixMix* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool FixMixPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FixMixPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool FixMixPubSubType::deserialize( FixMix* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool FixMixPubSubType::deserialize( return true; } -std::function FixMixPubSubType::getSerializedSizeProvider( +uint32_t FixMixPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FixMixPubSubType::createData() + 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* FixMixPubSubType::create_data() { return reinterpret_cast(new FixMix()); } -void FixMixPubSubType::deleteData( +void FixMixPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FixMixPubSubType::getKey( +bool FixMixPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FixMix data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FixMixPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool FixMixPubSubType::getKey( const FixMix* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FixMix_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FixMix_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void FixMixPubSubType::register_type_object_representation() AutoidDefaultPubSubType::AutoidDefaultPubSubType() { - setName("AutoidDefault"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AutoidDefault::getMaxCdrSerializedSize()); -#else - AutoidDefault_max_cdr_typesize; -#endif + set_name("AutoidDefault"); + uint32_t type_size = AutoidDefault_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AutoidDefault_max_key_cdr_typesize > 16 ? AutoidDefault_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AutoidDefault_max_key_cdr_typesize > 16 ? AutoidDefault_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AutoidDefaultPubSubType::~AutoidDefaultPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AutoidDefaultPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AutoidDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool AutoidDefaultPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AutoidDefaultPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool AutoidDefaultPubSubType::deserialize( AutoidDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool AutoidDefaultPubSubType::deserialize( return true; } -std::function AutoidDefaultPubSubType::getSerializedSizeProvider( +uint32_t AutoidDefaultPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AutoidDefaultPubSubType::createData() + 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* AutoidDefaultPubSubType::create_data() { return reinterpret_cast(new AutoidDefault()); } -void AutoidDefaultPubSubType::deleteData( +void AutoidDefaultPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AutoidDefaultPubSubType::getKey( +bool AutoidDefaultPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AutoidDefault data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AutoidDefaultPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool AutoidDefaultPubSubType::getKey( const AutoidDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AutoidDefault_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AutoidDefault_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void AutoidDefaultPubSubType::register_type_object_representation() AutoidSequentialPubSubType::AutoidSequentialPubSubType() { - setName("AutoidSequential"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AutoidSequential::getMaxCdrSerializedSize()); -#else - AutoidSequential_max_cdr_typesize; -#endif + set_name("AutoidSequential"); + uint32_t type_size = AutoidSequential_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AutoidSequential_max_key_cdr_typesize > 16 ? AutoidSequential_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AutoidSequential_max_key_cdr_typesize > 16 ? AutoidSequential_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AutoidSequentialPubSubType::~AutoidSequentialPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AutoidSequentialPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AutoidSequential* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool AutoidSequentialPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AutoidSequentialPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool AutoidSequentialPubSubType::deserialize( AutoidSequential* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool AutoidSequentialPubSubType::deserialize( return true; } -std::function AutoidSequentialPubSubType::getSerializedSizeProvider( +uint32_t AutoidSequentialPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AutoidSequentialPubSubType::createData() + 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* AutoidSequentialPubSubType::create_data() { return reinterpret_cast(new AutoidSequential()); } -void AutoidSequentialPubSubType::deleteData( +void AutoidSequentialPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AutoidSequentialPubSubType::getKey( +bool AutoidSequentialPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AutoidSequential data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AutoidSequentialPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool AutoidSequentialPubSubType::getKey( const AutoidSequential* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AutoidSequential_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AutoidSequential_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void AutoidSequentialPubSubType::register_type_object_representation() AutoidHashPubSubType::AutoidHashPubSubType() { - setName("AutoidHash"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AutoidHash::getMaxCdrSerializedSize()); -#else - AutoidHash_max_cdr_typesize; -#endif + set_name("AutoidHash"); + uint32_t type_size = AutoidHash_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AutoidHash_max_key_cdr_typesize > 16 ? AutoidHash_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AutoidHash_max_key_cdr_typesize > 16 ? AutoidHash_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AutoidHashPubSubType::~AutoidHashPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AutoidHashPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AutoidHash* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool AutoidHashPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AutoidHashPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool AutoidHashPubSubType::deserialize( AutoidHash* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool AutoidHashPubSubType::deserialize( return true; } -std::function AutoidHashPubSubType::getSerializedSizeProvider( +uint32_t AutoidHashPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AutoidHashPubSubType::createData() + 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* AutoidHashPubSubType::create_data() { return reinterpret_cast(new AutoidHash()); } -void AutoidHashPubSubType::deleteData( +void AutoidHashPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AutoidHashPubSubType::getKey( +bool AutoidHashPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AutoidHash data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AutoidHashPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool AutoidHashPubSubType::getKey( const AutoidHash* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AutoidHash_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AutoidHash_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void AutoidHashPubSubType::register_type_object_representation() DerivedAutoidDefaultPubSubType::DerivedAutoidDefaultPubSubType() { - setName("DerivedAutoidDefault"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DerivedAutoidDefault::getMaxCdrSerializedSize()); -#else - DerivedAutoidDefault_max_cdr_typesize; -#endif + set_name("DerivedAutoidDefault"); + uint32_t type_size = DerivedAutoidDefault_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DerivedAutoidDefault_max_key_cdr_typesize > 16 ? DerivedAutoidDefault_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = DerivedAutoidDefault_max_key_cdr_typesize > 16 ? DerivedAutoidDefault_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DerivedAutoidDefaultPubSubType::~DerivedAutoidDefaultPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DerivedAutoidDefaultPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const DerivedAutoidDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool DerivedAutoidDefaultPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DerivedAutoidDefaultPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool DerivedAutoidDefaultPubSubType::deserialize( DerivedAutoidDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool DerivedAutoidDefaultPubSubType::deserialize( return true; } -std::function DerivedAutoidDefaultPubSubType::getSerializedSizeProvider( +uint32_t DerivedAutoidDefaultPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DerivedAutoidDefaultPubSubType::createData() + 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* DerivedAutoidDefaultPubSubType::create_data() { return reinterpret_cast(new DerivedAutoidDefault()); } -void DerivedAutoidDefaultPubSubType::deleteData( +void DerivedAutoidDefaultPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool DerivedAutoidDefaultPubSubType::getKey( +bool DerivedAutoidDefaultPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + DerivedAutoidDefault data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool DerivedAutoidDefaultPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool DerivedAutoidDefaultPubSubType::getKey( const DerivedAutoidDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), DerivedAutoidDefault_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || DerivedAutoidDefault_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void DerivedAutoidDefaultPubSubType::register_type_object_representation() DerivedEmptyAutoidSequentialPubSubType::DerivedEmptyAutoidSequentialPubSubType() { - setName("DerivedEmptyAutoidSequential"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DerivedEmptyAutoidSequential::getMaxCdrSerializedSize()); -#else - DerivedEmptyAutoidSequential_max_cdr_typesize; -#endif + set_name("DerivedEmptyAutoidSequential"); + uint32_t type_size = DerivedEmptyAutoidSequential_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DerivedEmptyAutoidSequential_max_key_cdr_typesize > 16 ? DerivedEmptyAutoidSequential_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = DerivedEmptyAutoidSequential_max_key_cdr_typesize > 16 ? DerivedEmptyAutoidSequential_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DerivedEmptyAutoidSequentialPubSubType::~DerivedEmptyAutoidSequentialPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DerivedEmptyAutoidSequentialPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const DerivedEmptyAutoidSequential* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool DerivedEmptyAutoidSequentialPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DerivedEmptyAutoidSequentialPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool DerivedEmptyAutoidSequentialPubSubType::deserialize( DerivedEmptyAutoidSequential* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool DerivedEmptyAutoidSequentialPubSubType::deserialize( return true; } -std::function DerivedEmptyAutoidSequentialPubSubType::getSerializedSizeProvider( +uint32_t DerivedEmptyAutoidSequentialPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DerivedEmptyAutoidSequentialPubSubType::createData() + 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* DerivedEmptyAutoidSequentialPubSubType::create_data() { return reinterpret_cast(new DerivedEmptyAutoidSequential()); } -void DerivedEmptyAutoidSequentialPubSubType::deleteData( +void DerivedEmptyAutoidSequentialPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool DerivedEmptyAutoidSequentialPubSubType::getKey( +bool DerivedEmptyAutoidSequentialPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + DerivedEmptyAutoidSequential data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool DerivedEmptyAutoidSequentialPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool DerivedEmptyAutoidSequentialPubSubType::getKey( const DerivedEmptyAutoidSequential* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), DerivedEmptyAutoidSequential_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || DerivedEmptyAutoidSequential_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void DerivedEmptyAutoidSequentialPubSubType::register_type_object_representation DerivedAutoidSequentialPubSubType::DerivedAutoidSequentialPubSubType() { - setName("DerivedAutoidSequential"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DerivedAutoidSequential::getMaxCdrSerializedSize()); -#else - DerivedAutoidSequential_max_cdr_typesize; -#endif + set_name("DerivedAutoidSequential"); + uint32_t type_size = DerivedAutoidSequential_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DerivedAutoidSequential_max_key_cdr_typesize > 16 ? DerivedAutoidSequential_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = DerivedAutoidSequential_max_key_cdr_typesize > 16 ? DerivedAutoidSequential_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DerivedAutoidSequentialPubSubType::~DerivedAutoidSequentialPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DerivedAutoidSequentialPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const DerivedAutoidSequential* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool DerivedAutoidSequentialPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DerivedAutoidSequentialPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool DerivedAutoidSequentialPubSubType::deserialize( DerivedAutoidSequential* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool DerivedAutoidSequentialPubSubType::deserialize( return true; } -std::function DerivedAutoidSequentialPubSubType::getSerializedSizeProvider( +uint32_t DerivedAutoidSequentialPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DerivedAutoidSequentialPubSubType::createData() + 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* DerivedAutoidSequentialPubSubType::create_data() { return reinterpret_cast(new DerivedAutoidSequential()); } -void DerivedAutoidSequentialPubSubType::deleteData( +void DerivedAutoidSequentialPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool DerivedAutoidSequentialPubSubType::getKey( +bool DerivedAutoidSequentialPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + DerivedAutoidSequential data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool DerivedAutoidSequentialPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool DerivedAutoidSequentialPubSubType::getKey( const DerivedAutoidSequential* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), DerivedAutoidSequential_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || DerivedAutoidSequential_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void DerivedAutoidSequentialPubSubType::register_type_object_representation() DerivedAutoidHashPubSubType::DerivedAutoidHashPubSubType() { - setName("DerivedAutoidHash"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DerivedAutoidHash::getMaxCdrSerializedSize()); -#else - DerivedAutoidHash_max_cdr_typesize; -#endif + set_name("DerivedAutoidHash"); + uint32_t type_size = DerivedAutoidHash_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DerivedAutoidHash_max_key_cdr_typesize > 16 ? DerivedAutoidHash_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = DerivedAutoidHash_max_key_cdr_typesize > 16 ? DerivedAutoidHash_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DerivedAutoidHashPubSubType::~DerivedAutoidHashPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DerivedAutoidHashPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const DerivedAutoidHash* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool DerivedAutoidHashPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DerivedAutoidHashPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool DerivedAutoidHashPubSubType::deserialize( DerivedAutoidHash* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool DerivedAutoidHashPubSubType::deserialize( return true; } -std::function DerivedAutoidHashPubSubType::getSerializedSizeProvider( +uint32_t DerivedAutoidHashPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DerivedAutoidHashPubSubType::createData() + 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* DerivedAutoidHashPubSubType::create_data() { return reinterpret_cast(new DerivedAutoidHash()); } -void DerivedAutoidHashPubSubType::deleteData( +void DerivedAutoidHashPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool DerivedAutoidHashPubSubType::getKey( +bool DerivedAutoidHashPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + DerivedAutoidHash data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool DerivedAutoidHashPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool DerivedAutoidHashPubSubType::getKey( const DerivedAutoidHash* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), DerivedAutoidHash_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || DerivedAutoidHash_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/member_idPubSubTypes.hpp b/test/dds-types-test/member_idPubSubTypes.hpp index 676c0df01cc..4ab02678028 100644 --- a/test/dds-types-test/member_idPubSubTypes.hpp +++ b/test/dds-types-test/member_idPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "member_id.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated member_id is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class FixIdPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class FixIdPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class FixIdPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -145,38 +135,30 @@ class FixHexIdPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -191,10 +173,6 @@ class FixHexIdPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,8 +193,10 @@ class FixHexIdPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -236,38 +216,30 @@ class FixHashidDefaultPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -282,10 +254,6 @@ class FixHashidDefaultPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -306,8 +274,10 @@ class FixHashidDefaultPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -327,38 +297,30 @@ class FixHashidPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -373,10 +335,6 @@ class FixHashidPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -397,8 +355,10 @@ class FixHashidPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -418,38 +378,30 @@ class FixMixPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -464,10 +416,6 @@ class FixMixPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -488,8 +436,10 @@ class FixMixPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -509,38 +459,30 @@ class AutoidDefaultPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -555,10 +497,6 @@ class AutoidDefaultPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -579,8 +517,10 @@ class AutoidDefaultPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -600,38 +540,30 @@ class AutoidSequentialPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -646,10 +578,6 @@ class AutoidSequentialPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -670,8 +598,10 @@ class AutoidSequentialPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -691,38 +621,30 @@ class AutoidHashPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -737,10 +659,6 @@ class AutoidHashPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -761,8 +679,10 @@ class AutoidHashPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -782,38 +702,30 @@ class DerivedAutoidDefaultPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -828,10 +740,6 @@ class DerivedAutoidDefaultPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -852,8 +760,10 @@ class DerivedAutoidDefaultPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -873,38 +783,30 @@ class DerivedEmptyAutoidSequentialPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -919,10 +821,6 @@ class DerivedEmptyAutoidSequentialPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -943,8 +841,10 @@ class DerivedEmptyAutoidSequentialPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -964,38 +864,30 @@ class DerivedAutoidSequentialPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1010,10 +902,6 @@ class DerivedAutoidSequentialPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1034,8 +922,10 @@ class DerivedAutoidSequentialPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1055,38 +945,30 @@ class DerivedAutoidHashPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1101,10 +983,6 @@ class DerivedAutoidHashPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1125,8 +1003,10 @@ class DerivedAutoidHashPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/mutablePubSubTypes.cxx b/test/dds-types-test/mutablePubSubTypes.cxx index 2b9db087693..cd6da357e11 100644 --- a/test/dds-types-test/mutablePubSubTypes.cxx +++ b/test/dds-types-test/mutablePubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; MutableShortStructPubSubType::MutableShortStructPubSubType() { - setName("MutableShortStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableShortStruct::getMaxCdrSerializedSize()); -#else - MutableShortStruct_max_cdr_typesize; -#endif + set_name("MutableShortStruct"); + uint32_t type_size = MutableShortStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableShortStruct_max_key_cdr_typesize > 16 ? MutableShortStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableShortStruct_max_key_cdr_typesize > 16 ? MutableShortStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableShortStructPubSubType::~MutableShortStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableShortStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool MutableShortStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableShortStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool MutableShortStructPubSubType::deserialize( MutableShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool MutableShortStructPubSubType::deserialize( return true; } -std::function MutableShortStructPubSubType::getSerializedSizeProvider( +uint32_t MutableShortStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableShortStructPubSubType::createData() + 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* MutableShortStructPubSubType::create_data() { return reinterpret_cast(new MutableShortStruct()); } -void MutableShortStructPubSubType::deleteData( +void MutableShortStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableShortStructPubSubType::getKey( +bool MutableShortStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableShortStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableShortStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool MutableShortStructPubSubType::getKey( const MutableShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableShortStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableShortStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void MutableShortStructPubSubType::register_type_object_representation() MutableUShortStructPubSubType::MutableUShortStructPubSubType() { - setName("MutableUShortStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableUShortStruct::getMaxCdrSerializedSize()); -#else - MutableUShortStruct_max_cdr_typesize; -#endif + set_name("MutableUShortStruct"); + uint32_t type_size = MutableUShortStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableUShortStruct_max_key_cdr_typesize > 16 ? MutableUShortStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableUShortStruct_max_key_cdr_typesize > 16 ? MutableUShortStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableUShortStructPubSubType::~MutableUShortStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableUShortStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool MutableUShortStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableUShortStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool MutableUShortStructPubSubType::deserialize( MutableUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool MutableUShortStructPubSubType::deserialize( return true; } -std::function MutableUShortStructPubSubType::getSerializedSizeProvider( +uint32_t MutableUShortStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableUShortStructPubSubType::createData() + 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* MutableUShortStructPubSubType::create_data() { return reinterpret_cast(new MutableUShortStruct()); } -void MutableUShortStructPubSubType::deleteData( +void MutableUShortStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableUShortStructPubSubType::getKey( +bool MutableUShortStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableUShortStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableUShortStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool MutableUShortStructPubSubType::getKey( const MutableUShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableUShortStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableUShortStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void MutableUShortStructPubSubType::register_type_object_representation() MutableLongStructPubSubType::MutableLongStructPubSubType() { - setName("MutableLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableLongStruct::getMaxCdrSerializedSize()); -#else - MutableLongStruct_max_cdr_typesize; -#endif + set_name("MutableLongStruct"); + uint32_t type_size = MutableLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableLongStruct_max_key_cdr_typesize > 16 ? MutableLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableLongStruct_max_key_cdr_typesize > 16 ? MutableLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableLongStructPubSubType::~MutableLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool MutableLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool MutableLongStructPubSubType::deserialize( MutableLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool MutableLongStructPubSubType::deserialize( return true; } -std::function MutableLongStructPubSubType::getSerializedSizeProvider( +uint32_t MutableLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableLongStructPubSubType::createData() + 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* MutableLongStructPubSubType::create_data() { return reinterpret_cast(new MutableLongStruct()); } -void MutableLongStructPubSubType::deleteData( +void MutableLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableLongStructPubSubType::getKey( +bool MutableLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool MutableLongStructPubSubType::getKey( const MutableLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void MutableLongStructPubSubType::register_type_object_representation() MutableULongStructPubSubType::MutableULongStructPubSubType() { - setName("MutableULongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableULongStruct::getMaxCdrSerializedSize()); -#else - MutableULongStruct_max_cdr_typesize; -#endif + set_name("MutableULongStruct"); + uint32_t type_size = MutableULongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableULongStruct_max_key_cdr_typesize > 16 ? MutableULongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableULongStruct_max_key_cdr_typesize > 16 ? MutableULongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableULongStructPubSubType::~MutableULongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableULongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool MutableULongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableULongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool MutableULongStructPubSubType::deserialize( MutableULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool MutableULongStructPubSubType::deserialize( return true; } -std::function MutableULongStructPubSubType::getSerializedSizeProvider( +uint32_t MutableULongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableULongStructPubSubType::createData() + 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* MutableULongStructPubSubType::create_data() { return reinterpret_cast(new MutableULongStruct()); } -void MutableULongStructPubSubType::deleteData( +void MutableULongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableULongStructPubSubType::getKey( +bool MutableULongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableULongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableULongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool MutableULongStructPubSubType::getKey( const MutableULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableULongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableULongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void MutableULongStructPubSubType::register_type_object_representation() MutableLongLongStructPubSubType::MutableLongLongStructPubSubType() { - setName("MutableLongLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableLongLongStruct::getMaxCdrSerializedSize()); -#else - MutableLongLongStruct_max_cdr_typesize; -#endif + set_name("MutableLongLongStruct"); + uint32_t type_size = MutableLongLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableLongLongStruct_max_key_cdr_typesize > 16 ? MutableLongLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableLongLongStruct_max_key_cdr_typesize > 16 ? MutableLongLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableLongLongStructPubSubType::~MutableLongLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableLongLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool MutableLongLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableLongLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool MutableLongLongStructPubSubType::deserialize( MutableLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool MutableLongLongStructPubSubType::deserialize( return true; } -std::function MutableLongLongStructPubSubType::getSerializedSizeProvider( +uint32_t MutableLongLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableLongLongStructPubSubType::createData() + 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* MutableLongLongStructPubSubType::create_data() { return reinterpret_cast(new MutableLongLongStruct()); } -void MutableLongLongStructPubSubType::deleteData( +void MutableLongLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableLongLongStructPubSubType::getKey( +bool MutableLongLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableLongLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableLongLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool MutableLongLongStructPubSubType::getKey( const MutableLongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableLongLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableLongLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void MutableLongLongStructPubSubType::register_type_object_representation() MutableULongLongStructPubSubType::MutableULongLongStructPubSubType() { - setName("MutableULongLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableULongLongStruct::getMaxCdrSerializedSize()); -#else - MutableULongLongStruct_max_cdr_typesize; -#endif + set_name("MutableULongLongStruct"); + uint32_t type_size = MutableULongLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableULongLongStruct_max_key_cdr_typesize > 16 ? MutableULongLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableULongLongStruct_max_key_cdr_typesize > 16 ? MutableULongLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableULongLongStructPubSubType::~MutableULongLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableULongLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool MutableULongLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableULongLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool MutableULongLongStructPubSubType::deserialize( MutableULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool MutableULongLongStructPubSubType::deserialize( return true; } -std::function MutableULongLongStructPubSubType::getSerializedSizeProvider( +uint32_t MutableULongLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableULongLongStructPubSubType::createData() + 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* MutableULongLongStructPubSubType::create_data() { return reinterpret_cast(new MutableULongLongStruct()); } -void MutableULongLongStructPubSubType::deleteData( +void MutableULongLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableULongLongStructPubSubType::getKey( +bool MutableULongLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableULongLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableULongLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool MutableULongLongStructPubSubType::getKey( const MutableULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableULongLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableULongLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void MutableULongLongStructPubSubType::register_type_object_representation() MutableFloatStructPubSubType::MutableFloatStructPubSubType() { - setName("MutableFloatStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableFloatStruct::getMaxCdrSerializedSize()); -#else - MutableFloatStruct_max_cdr_typesize; -#endif + set_name("MutableFloatStruct"); + uint32_t type_size = MutableFloatStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableFloatStruct_max_key_cdr_typesize > 16 ? MutableFloatStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableFloatStruct_max_key_cdr_typesize > 16 ? MutableFloatStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableFloatStructPubSubType::~MutableFloatStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableFloatStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool MutableFloatStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableFloatStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool MutableFloatStructPubSubType::deserialize( MutableFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool MutableFloatStructPubSubType::deserialize( return true; } -std::function MutableFloatStructPubSubType::getSerializedSizeProvider( +uint32_t MutableFloatStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableFloatStructPubSubType::createData() + 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* MutableFloatStructPubSubType::create_data() { return reinterpret_cast(new MutableFloatStruct()); } -void MutableFloatStructPubSubType::deleteData( +void MutableFloatStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableFloatStructPubSubType::getKey( +bool MutableFloatStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableFloatStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableFloatStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool MutableFloatStructPubSubType::getKey( const MutableFloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableFloatStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableFloatStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void MutableFloatStructPubSubType::register_type_object_representation() MutableDoubleStructPubSubType::MutableDoubleStructPubSubType() { - setName("MutableDoubleStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableDoubleStruct::getMaxCdrSerializedSize()); -#else - MutableDoubleStruct_max_cdr_typesize; -#endif + set_name("MutableDoubleStruct"); + uint32_t type_size = MutableDoubleStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableDoubleStruct_max_key_cdr_typesize > 16 ? MutableDoubleStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableDoubleStruct_max_key_cdr_typesize > 16 ? MutableDoubleStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableDoubleStructPubSubType::~MutableDoubleStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableDoubleStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool MutableDoubleStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableDoubleStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool MutableDoubleStructPubSubType::deserialize( MutableDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool MutableDoubleStructPubSubType::deserialize( return true; } -std::function MutableDoubleStructPubSubType::getSerializedSizeProvider( +uint32_t MutableDoubleStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableDoubleStructPubSubType::createData() + 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* MutableDoubleStructPubSubType::create_data() { return reinterpret_cast(new MutableDoubleStruct()); } -void MutableDoubleStructPubSubType::deleteData( +void MutableDoubleStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableDoubleStructPubSubType::getKey( +bool MutableDoubleStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableDoubleStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableDoubleStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool MutableDoubleStructPubSubType::getKey( const MutableDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableDoubleStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableDoubleStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void MutableDoubleStructPubSubType::register_type_object_representation() MutableLongDoubleStructPubSubType::MutableLongDoubleStructPubSubType() { - setName("MutableLongDoubleStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableLongDoubleStruct::getMaxCdrSerializedSize()); -#else - MutableLongDoubleStruct_max_cdr_typesize; -#endif + set_name("MutableLongDoubleStruct"); + uint32_t type_size = MutableLongDoubleStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableLongDoubleStruct_max_key_cdr_typesize > 16 ? MutableLongDoubleStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableLongDoubleStruct_max_key_cdr_typesize > 16 ? MutableLongDoubleStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableLongDoubleStructPubSubType::~MutableLongDoubleStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableLongDoubleStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool MutableLongDoubleStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableLongDoubleStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool MutableLongDoubleStructPubSubType::deserialize( MutableLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool MutableLongDoubleStructPubSubType::deserialize( return true; } -std::function MutableLongDoubleStructPubSubType::getSerializedSizeProvider( +uint32_t MutableLongDoubleStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableLongDoubleStructPubSubType::createData() + 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* MutableLongDoubleStructPubSubType::create_data() { return reinterpret_cast(new MutableLongDoubleStruct()); } -void MutableLongDoubleStructPubSubType::deleteData( +void MutableLongDoubleStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableLongDoubleStructPubSubType::getKey( +bool MutableLongDoubleStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableLongDoubleStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableLongDoubleStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool MutableLongDoubleStructPubSubType::getKey( const MutableLongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableLongDoubleStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableLongDoubleStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void MutableLongDoubleStructPubSubType::register_type_object_representation() MutableBooleanStructPubSubType::MutableBooleanStructPubSubType() { - setName("MutableBooleanStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableBooleanStruct::getMaxCdrSerializedSize()); -#else - MutableBooleanStruct_max_cdr_typesize; -#endif + set_name("MutableBooleanStruct"); + uint32_t type_size = MutableBooleanStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableBooleanStruct_max_key_cdr_typesize > 16 ? MutableBooleanStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableBooleanStruct_max_key_cdr_typesize > 16 ? MutableBooleanStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableBooleanStructPubSubType::~MutableBooleanStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableBooleanStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool MutableBooleanStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableBooleanStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool MutableBooleanStructPubSubType::deserialize( MutableBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool MutableBooleanStructPubSubType::deserialize( return true; } -std::function MutableBooleanStructPubSubType::getSerializedSizeProvider( +uint32_t MutableBooleanStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableBooleanStructPubSubType::createData() + 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* MutableBooleanStructPubSubType::create_data() { return reinterpret_cast(new MutableBooleanStruct()); } -void MutableBooleanStructPubSubType::deleteData( +void MutableBooleanStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableBooleanStructPubSubType::getKey( +bool MutableBooleanStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableBooleanStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableBooleanStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool MutableBooleanStructPubSubType::getKey( const MutableBooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableBooleanStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableBooleanStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void MutableBooleanStructPubSubType::register_type_object_representation() MutableOctetStructPubSubType::MutableOctetStructPubSubType() { - setName("MutableOctetStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableOctetStruct::getMaxCdrSerializedSize()); -#else - MutableOctetStruct_max_cdr_typesize; -#endif + set_name("MutableOctetStruct"); + uint32_t type_size = MutableOctetStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableOctetStruct_max_key_cdr_typesize > 16 ? MutableOctetStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableOctetStruct_max_key_cdr_typesize > 16 ? MutableOctetStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableOctetStructPubSubType::~MutableOctetStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableOctetStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool MutableOctetStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableOctetStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool MutableOctetStructPubSubType::deserialize( MutableOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool MutableOctetStructPubSubType::deserialize( return true; } -std::function MutableOctetStructPubSubType::getSerializedSizeProvider( +uint32_t MutableOctetStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableOctetStructPubSubType::createData() + 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* MutableOctetStructPubSubType::create_data() { return reinterpret_cast(new MutableOctetStruct()); } -void MutableOctetStructPubSubType::deleteData( +void MutableOctetStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableOctetStructPubSubType::getKey( +bool MutableOctetStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableOctetStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableOctetStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool MutableOctetStructPubSubType::getKey( const MutableOctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableOctetStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableOctetStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void MutableOctetStructPubSubType::register_type_object_representation() MutableCharStructPubSubType::MutableCharStructPubSubType() { - setName("MutableCharStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableCharStruct::getMaxCdrSerializedSize()); -#else - MutableCharStruct_max_cdr_typesize; -#endif + set_name("MutableCharStruct"); + uint32_t type_size = MutableCharStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableCharStruct_max_key_cdr_typesize > 16 ? MutableCharStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableCharStruct_max_key_cdr_typesize > 16 ? MutableCharStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableCharStructPubSubType::~MutableCharStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableCharStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool MutableCharStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableCharStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool MutableCharStructPubSubType::deserialize( MutableCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool MutableCharStructPubSubType::deserialize( return true; } -std::function MutableCharStructPubSubType::getSerializedSizeProvider( +uint32_t MutableCharStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableCharStructPubSubType::createData() + 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* MutableCharStructPubSubType::create_data() { return reinterpret_cast(new MutableCharStruct()); } -void MutableCharStructPubSubType::deleteData( +void MutableCharStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableCharStructPubSubType::getKey( +bool MutableCharStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableCharStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableCharStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool MutableCharStructPubSubType::getKey( const MutableCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableCharStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableCharStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void MutableCharStructPubSubType::register_type_object_representation() MutableWCharStructPubSubType::MutableWCharStructPubSubType() { - setName("MutableWCharStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableWCharStruct::getMaxCdrSerializedSize()); -#else - MutableWCharStruct_max_cdr_typesize; -#endif + set_name("MutableWCharStruct"); + uint32_t type_size = MutableWCharStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableWCharStruct_max_key_cdr_typesize > 16 ? MutableWCharStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableWCharStruct_max_key_cdr_typesize > 16 ? MutableWCharStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableWCharStructPubSubType::~MutableWCharStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableWCharStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool MutableWCharStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableWCharStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool MutableWCharStructPubSubType::deserialize( MutableWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,52 +2277,62 @@ bool MutableWCharStructPubSubType::deserialize( return true; } -std::function MutableWCharStructPubSubType::getSerializedSizeProvider( +uint32_t MutableWCharStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableWCharStructPubSubType::createData() + 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* MutableWCharStructPubSubType::create_data() { return reinterpret_cast(new MutableWCharStruct()); } -void MutableWCharStructPubSubType::deleteData( +void MutableWCharStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableWCharStructPubSubType::getKey( +bool MutableWCharStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableWCharStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableWCharStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2501,35 +2340,27 @@ bool MutableWCharStructPubSubType::getKey( const MutableWCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableWCharStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableWCharStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void MutableWCharStructPubSubType::register_type_object_representation() MutableUnionStructPubSubType::MutableUnionStructPubSubType() { - setName("MutableUnionStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableUnionStruct::getMaxCdrSerializedSize()); -#else - MutableUnionStruct_max_cdr_typesize; -#endif + set_name("MutableUnionStruct"); + uint32_t type_size = MutableUnionStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableUnionStruct_max_key_cdr_typesize > 16 ? MutableUnionStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableUnionStruct_max_key_cdr_typesize > 16 ? MutableUnionStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableUnionStructPubSubType::~MutableUnionStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableUnionStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableUnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool MutableUnionStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableUnionStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool MutableUnionStructPubSubType::deserialize( MutableUnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool MutableUnionStructPubSubType::deserialize( return true; } -std::function MutableUnionStructPubSubType::getSerializedSizeProvider( +uint32_t MutableUnionStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableUnionStructPubSubType::createData() + 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* MutableUnionStructPubSubType::create_data() { return reinterpret_cast(new MutableUnionStruct()); } -void MutableUnionStructPubSubType::deleteData( +void MutableUnionStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableUnionStructPubSubType::getKey( +bool MutableUnionStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableUnionStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableUnionStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool MutableUnionStructPubSubType::getKey( const MutableUnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableUnionStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableUnionStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void MutableUnionStructPubSubType::register_type_object_representation() MutableEmptyStructPubSubType::MutableEmptyStructPubSubType() { - setName("MutableEmptyStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableEmptyStruct::getMaxCdrSerializedSize()); -#else - MutableEmptyStruct_max_cdr_typesize; -#endif + set_name("MutableEmptyStruct"); + uint32_t type_size = MutableEmptyStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableEmptyStruct_max_key_cdr_typesize > 16 ? MutableEmptyStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableEmptyStruct_max_key_cdr_typesize > 16 ? MutableEmptyStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableEmptyStructPubSubType::~MutableEmptyStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableEmptyStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool MutableEmptyStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableEmptyStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool MutableEmptyStructPubSubType::deserialize( MutableEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool MutableEmptyStructPubSubType::deserialize( return true; } -std::function MutableEmptyStructPubSubType::getSerializedSizeProvider( +uint32_t MutableEmptyStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableEmptyStructPubSubType::createData() + 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* MutableEmptyStructPubSubType::create_data() { return reinterpret_cast(new MutableEmptyStruct()); } -void MutableEmptyStructPubSubType::deleteData( +void MutableEmptyStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableEmptyStructPubSubType::getKey( +bool MutableEmptyStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableEmptyStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableEmptyStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool MutableEmptyStructPubSubType::getKey( const MutableEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableEmptyStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableEmptyStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void MutableEmptyStructPubSubType::register_type_object_representation() MutableEmptyInheritanceStructPubSubType::MutableEmptyInheritanceStructPubSubType() { - setName("MutableEmptyInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableEmptyInheritanceStruct::getMaxCdrSerializedSize()); -#else - MutableEmptyInheritanceStruct_max_cdr_typesize; -#endif + set_name("MutableEmptyInheritanceStruct"); + uint32_t type_size = MutableEmptyInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableEmptyInheritanceStruct_max_key_cdr_typesize > 16 ? MutableEmptyInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableEmptyInheritanceStruct_max_key_cdr_typesize > 16 ? MutableEmptyInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableEmptyInheritanceStructPubSubType::~MutableEmptyInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableEmptyInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool MutableEmptyInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableEmptyInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool MutableEmptyInheritanceStructPubSubType::deserialize( MutableEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool MutableEmptyInheritanceStructPubSubType::deserialize( return true; } -std::function MutableEmptyInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t MutableEmptyInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableEmptyInheritanceStructPubSubType::createData() + 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* MutableEmptyInheritanceStructPubSubType::create_data() { return reinterpret_cast(new MutableEmptyInheritanceStruct()); } -void MutableEmptyInheritanceStructPubSubType::deleteData( +void MutableEmptyInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableEmptyInheritanceStructPubSubType::getKey( +bool MutableEmptyInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableEmptyInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableEmptyInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool MutableEmptyInheritanceStructPubSubType::getKey( const MutableEmptyInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableEmptyInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableEmptyInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void MutableEmptyInheritanceStructPubSubType::register_type_object_representatio MutableInheritanceStructPubSubType::MutableInheritanceStructPubSubType() { - setName("MutableInheritanceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableInheritanceStruct::getMaxCdrSerializedSize()); -#else - MutableInheritanceStruct_max_cdr_typesize; -#endif + set_name("MutableInheritanceStruct"); + uint32_t type_size = MutableInheritanceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableInheritanceStruct_max_key_cdr_typesize > 16 ? MutableInheritanceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableInheritanceStruct_max_key_cdr_typesize > 16 ? MutableInheritanceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableInheritanceStructPubSubType::~MutableInheritanceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableInheritanceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool MutableInheritanceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableInheritanceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool MutableInheritanceStructPubSubType::deserialize( MutableInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool MutableInheritanceStructPubSubType::deserialize( return true; } -std::function MutableInheritanceStructPubSubType::getSerializedSizeProvider( +uint32_t MutableInheritanceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableInheritanceStructPubSubType::createData() + 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* MutableInheritanceStructPubSubType::create_data() { return reinterpret_cast(new MutableInheritanceStruct()); } -void MutableInheritanceStructPubSubType::deleteData( +void MutableInheritanceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableInheritanceStructPubSubType::getKey( +bool MutableInheritanceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableInheritanceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableInheritanceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool MutableInheritanceStructPubSubType::getKey( const MutableInheritanceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableInheritanceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableInheritanceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void MutableInheritanceStructPubSubType::register_type_object_representation() MutableInheritanceEmptyStructPubSubType::MutableInheritanceEmptyStructPubSubType() { - setName("MutableInheritanceEmptyStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableInheritanceEmptyStruct::getMaxCdrSerializedSize()); -#else - MutableInheritanceEmptyStruct_max_cdr_typesize; -#endif + set_name("MutableInheritanceEmptyStruct"); + uint32_t type_size = MutableInheritanceEmptyStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableInheritanceEmptyStruct_max_key_cdr_typesize > 16 ? MutableInheritanceEmptyStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableInheritanceEmptyStruct_max_key_cdr_typesize > 16 ? MutableInheritanceEmptyStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableInheritanceEmptyStructPubSubType::~MutableInheritanceEmptyStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableInheritanceEmptyStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableInheritanceEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool MutableInheritanceEmptyStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableInheritanceEmptyStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool MutableInheritanceEmptyStructPubSubType::deserialize( MutableInheritanceEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool MutableInheritanceEmptyStructPubSubType::deserialize( return true; } -std::function MutableInheritanceEmptyStructPubSubType::getSerializedSizeProvider( +uint32_t MutableInheritanceEmptyStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableInheritanceEmptyStructPubSubType::createData() + 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* MutableInheritanceEmptyStructPubSubType::create_data() { return reinterpret_cast(new MutableInheritanceEmptyStruct()); } -void MutableInheritanceEmptyStructPubSubType::deleteData( +void MutableInheritanceEmptyStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableInheritanceEmptyStructPubSubType::getKey( +bool MutableInheritanceEmptyStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableInheritanceEmptyStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableInheritanceEmptyStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool MutableInheritanceEmptyStructPubSubType::getKey( const MutableInheritanceEmptyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableInheritanceEmptyStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableInheritanceEmptyStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void MutableInheritanceEmptyStructPubSubType::register_type_object_representatio MutableExtensibilityInheritancePubSubType::MutableExtensibilityInheritancePubSubType() { - setName("MutableExtensibilityInheritance"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableExtensibilityInheritance::getMaxCdrSerializedSize()); -#else - MutableExtensibilityInheritance_max_cdr_typesize; -#endif + set_name("MutableExtensibilityInheritance"); + uint32_t type_size = MutableExtensibilityInheritance_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableExtensibilityInheritance_max_key_cdr_typesize > 16 ? MutableExtensibilityInheritance_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableExtensibilityInheritance_max_key_cdr_typesize > 16 ? MutableExtensibilityInheritance_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableExtensibilityInheritancePubSubType::~MutableExtensibilityInheritancePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableExtensibilityInheritancePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableExtensibilityInheritance* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool MutableExtensibilityInheritancePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableExtensibilityInheritancePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool MutableExtensibilityInheritancePubSubType::deserialize( MutableExtensibilityInheritance* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool MutableExtensibilityInheritancePubSubType::deserialize( return true; } -std::function MutableExtensibilityInheritancePubSubType::getSerializedSizeProvider( +uint32_t MutableExtensibilityInheritancePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableExtensibilityInheritancePubSubType::createData() + 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* MutableExtensibilityInheritancePubSubType::create_data() { return reinterpret_cast(new MutableExtensibilityInheritance()); } -void MutableExtensibilityInheritancePubSubType::deleteData( +void MutableExtensibilityInheritancePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableExtensibilityInheritancePubSubType::getKey( +bool MutableExtensibilityInheritancePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableExtensibilityInheritance data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableExtensibilityInheritancePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool MutableExtensibilityInheritancePubSubType::getKey( const MutableExtensibilityInheritance* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableExtensibilityInheritance_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableExtensibilityInheritance_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/mutablePubSubTypes.hpp b/test/dds-types-test/mutablePubSubTypes.hpp index 5bb1f1652ca..d7c8411031d 100644 --- a/test/dds-types-test/mutablePubSubTypes.hpp +++ b/test/dds-types-test/mutablePubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated mutable is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class MutableShortStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class MutableShortStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class MutableShortStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class MutableUShortStructPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class MutableUShortStructPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class MutableUShortStructPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -237,38 +217,30 @@ class MutableLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -283,10 +255,6 @@ class MutableLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,8 +275,10 @@ class MutableLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -328,38 +298,30 @@ class MutableULongStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -374,10 +336,6 @@ class MutableULongStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -398,8 +356,10 @@ class MutableULongStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -419,38 +379,30 @@ class MutableLongLongStructPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -465,10 +417,6 @@ class MutableLongLongStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -489,8 +437,10 @@ class MutableLongLongStructPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -510,38 +460,30 @@ class MutableULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -556,10 +498,6 @@ class MutableULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -580,8 +518,10 @@ class MutableULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -601,38 +541,30 @@ class MutableFloatStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -647,10 +579,6 @@ class MutableFloatStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -671,8 +599,10 @@ class MutableFloatStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -692,38 +622,30 @@ class MutableDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -738,10 +660,6 @@ class MutableDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -762,8 +680,10 @@ class MutableDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -783,38 +703,30 @@ class MutableLongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -829,10 +741,6 @@ class MutableLongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -853,8 +761,10 @@ class MutableLongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -874,38 +784,30 @@ class MutableBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -920,10 +822,6 @@ class MutableBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -944,8 +842,10 @@ class MutableBooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -965,38 +865,30 @@ class MutableOctetStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1011,10 +903,6 @@ class MutableOctetStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1035,8 +923,10 @@ class MutableOctetStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1056,38 +946,30 @@ class MutableCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1102,10 +984,6 @@ class MutableCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1126,8 +1004,10 @@ class MutableCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1147,38 +1027,30 @@ class MutableWCharStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1193,10 +1065,6 @@ class MutableWCharStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1217,8 +1085,10 @@ class MutableWCharStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1238,38 +1108,30 @@ class MutableUnionStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1284,10 +1146,6 @@ class MutableUnionStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1308,8 +1166,10 @@ class MutableUnionStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1329,38 +1189,30 @@ class MutableEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1375,10 +1227,6 @@ class MutableEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1399,8 +1247,10 @@ class MutableEmptyStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1420,38 +1270,30 @@ class MutableEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1466,10 +1308,6 @@ class MutableEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1490,8 +1328,10 @@ class MutableEmptyInheritanceStructPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1511,38 +1351,30 @@ class MutableInheritanceStructPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1557,10 +1389,6 @@ class MutableInheritanceStructPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1581,8 +1409,10 @@ class MutableInheritanceStructPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1602,38 +1432,30 @@ class MutableInheritanceEmptyStructPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1648,10 +1470,6 @@ class MutableInheritanceEmptyStructPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1672,8 +1490,10 @@ class MutableInheritanceEmptyStructPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1693,38 +1513,30 @@ class MutableExtensibilityInheritancePubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1739,10 +1551,6 @@ class MutableExtensibilityInheritancePubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1763,8 +1571,10 @@ class MutableExtensibilityInheritancePubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/optionalPubSubTypes.cxx b/test/dds-types-test/optionalPubSubTypes.cxx index 9ecfe9f8a92..e954202f319 100644 --- a/test/dds-types-test/optionalPubSubTypes.cxx +++ b/test/dds-types-test/optionalPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; short_optionalPubSubType::short_optionalPubSubType() { - setName("short_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(short_optional::getMaxCdrSerializedSize()); -#else - short_optional_max_cdr_typesize; -#endif + set_name("short_optional"); + uint32_t type_size = short_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = short_optional_max_key_cdr_typesize > 16 ? short_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = short_optional_max_key_cdr_typesize > 16 ? short_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } short_optionalPubSubType::~short_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool short_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool short_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool short_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool short_optionalPubSubType::deserialize( short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool short_optionalPubSubType::deserialize( return true; } -std::function short_optionalPubSubType::getSerializedSizeProvider( +uint32_t short_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* short_optionalPubSubType::createData() +void* short_optionalPubSubType::create_data() { return reinterpret_cast(new short_optional()); } -void short_optionalPubSubType::deleteData( +void short_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool short_optionalPubSubType::getKey( +bool short_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + short_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool short_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool short_optionalPubSubType::getKey( const short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), short_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || short_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void short_optionalPubSubType::register_type_object_representation() ushort_optionalPubSubType::ushort_optionalPubSubType() { - setName("ushort_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ushort_optional::getMaxCdrSerializedSize()); -#else - ushort_optional_max_cdr_typesize; -#endif + set_name("ushort_optional"); + uint32_t type_size = ushort_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ushort_optional_max_key_cdr_typesize > 16 ? ushort_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ushort_optional_max_key_cdr_typesize > 16 ? ushort_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ushort_optionalPubSubType::~ushort_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ushort_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ushort_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool ushort_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ushort_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool ushort_optionalPubSubType::deserialize( ushort_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool ushort_optionalPubSubType::deserialize( return true; } -std::function ushort_optionalPubSubType::getSerializedSizeProvider( +uint32_t ushort_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ushort_optionalPubSubType::createData() +void* ushort_optionalPubSubType::create_data() { return reinterpret_cast(new ushort_optional()); } -void ushort_optionalPubSubType::deleteData( +void ushort_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ushort_optionalPubSubType::getKey( +bool ushort_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ushort_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ushort_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool ushort_optionalPubSubType::getKey( const ushort_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ushort_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ushort_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void ushort_optionalPubSubType::register_type_object_representation() long_optionalPubSubType::long_optionalPubSubType() { - setName("long_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(long_optional::getMaxCdrSerializedSize()); -#else - long_optional_max_cdr_typesize; -#endif + set_name("long_optional"); + uint32_t type_size = long_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = long_optional_max_key_cdr_typesize > 16 ? long_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = long_optional_max_key_cdr_typesize > 16 ? long_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } long_optionalPubSubType::~long_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool long_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const long_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool long_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool long_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool long_optionalPubSubType::deserialize( long_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool long_optionalPubSubType::deserialize( return true; } -std::function long_optionalPubSubType::getSerializedSizeProvider( +uint32_t long_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* long_optionalPubSubType::createData() +void* long_optionalPubSubType::create_data() { return reinterpret_cast(new long_optional()); } -void long_optionalPubSubType::deleteData( +void long_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool long_optionalPubSubType::getKey( +bool long_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + long_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool long_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool long_optionalPubSubType::getKey( const long_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), long_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || long_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void long_optionalPubSubType::register_type_object_representation() ulong_optionalPubSubType::ulong_optionalPubSubType() { - setName("ulong_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ulong_optional::getMaxCdrSerializedSize()); -#else - ulong_optional_max_cdr_typesize; -#endif + set_name("ulong_optional"); + uint32_t type_size = ulong_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ulong_optional_max_key_cdr_typesize > 16 ? ulong_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ulong_optional_max_key_cdr_typesize > 16 ? ulong_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ulong_optionalPubSubType::~ulong_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ulong_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ulong_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool ulong_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ulong_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool ulong_optionalPubSubType::deserialize( ulong_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool ulong_optionalPubSubType::deserialize( return true; } -std::function ulong_optionalPubSubType::getSerializedSizeProvider( +uint32_t ulong_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ulong_optionalPubSubType::createData() +void* ulong_optionalPubSubType::create_data() { return reinterpret_cast(new ulong_optional()); } -void ulong_optionalPubSubType::deleteData( +void ulong_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ulong_optionalPubSubType::getKey( +bool ulong_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ulong_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ulong_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool ulong_optionalPubSubType::getKey( const ulong_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ulong_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ulong_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void ulong_optionalPubSubType::register_type_object_representation() longlong_optionalPubSubType::longlong_optionalPubSubType() { - setName("longlong_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(longlong_optional::getMaxCdrSerializedSize()); -#else - longlong_optional_max_cdr_typesize; -#endif + set_name("longlong_optional"); + uint32_t type_size = longlong_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = longlong_optional_max_key_cdr_typesize > 16 ? longlong_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = longlong_optional_max_key_cdr_typesize > 16 ? longlong_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } longlong_optionalPubSubType::~longlong_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool longlong_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const longlong_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool longlong_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool longlong_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool longlong_optionalPubSubType::deserialize( longlong_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool longlong_optionalPubSubType::deserialize( return true; } -std::function longlong_optionalPubSubType::getSerializedSizeProvider( +uint32_t longlong_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* longlong_optionalPubSubType::createData() +void* longlong_optionalPubSubType::create_data() { return reinterpret_cast(new longlong_optional()); } -void longlong_optionalPubSubType::deleteData( +void longlong_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool longlong_optionalPubSubType::getKey( +bool longlong_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + longlong_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool longlong_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool longlong_optionalPubSubType::getKey( const longlong_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), longlong_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || longlong_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void longlong_optionalPubSubType::register_type_object_representation() ulonglong_optionalPubSubType::ulonglong_optionalPubSubType() { - setName("ulonglong_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ulonglong_optional::getMaxCdrSerializedSize()); -#else - ulonglong_optional_max_cdr_typesize; -#endif + set_name("ulonglong_optional"); + uint32_t type_size = ulonglong_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ulonglong_optional_max_key_cdr_typesize > 16 ? ulonglong_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ulonglong_optional_max_key_cdr_typesize > 16 ? ulonglong_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ulonglong_optionalPubSubType::~ulonglong_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ulonglong_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ulonglong_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool ulonglong_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ulonglong_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool ulonglong_optionalPubSubType::deserialize( ulonglong_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool ulonglong_optionalPubSubType::deserialize( return true; } -std::function ulonglong_optionalPubSubType::getSerializedSizeProvider( +uint32_t ulonglong_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ulonglong_optionalPubSubType::createData() +void* ulonglong_optionalPubSubType::create_data() { return reinterpret_cast(new ulonglong_optional()); } -void ulonglong_optionalPubSubType::deleteData( +void ulonglong_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ulonglong_optionalPubSubType::getKey( +bool ulonglong_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ulonglong_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ulonglong_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool ulonglong_optionalPubSubType::getKey( const ulonglong_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ulonglong_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ulonglong_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void ulonglong_optionalPubSubType::register_type_object_representation() float_optionalPubSubType::float_optionalPubSubType() { - setName("float_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(float_optional::getMaxCdrSerializedSize()); -#else - float_optional_max_cdr_typesize; -#endif + set_name("float_optional"); + uint32_t type_size = float_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = float_optional_max_key_cdr_typesize > 16 ? float_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = float_optional_max_key_cdr_typesize > 16 ? float_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } float_optionalPubSubType::~float_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool float_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const float_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool float_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool float_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool float_optionalPubSubType::deserialize( float_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool float_optionalPubSubType::deserialize( return true; } -std::function float_optionalPubSubType::getSerializedSizeProvider( +uint32_t float_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* float_optionalPubSubType::createData() +void* float_optionalPubSubType::create_data() { return reinterpret_cast(new float_optional()); } -void float_optionalPubSubType::deleteData( +void float_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool float_optionalPubSubType::getKey( +bool float_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + float_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool float_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool float_optionalPubSubType::getKey( const float_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), float_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || float_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void float_optionalPubSubType::register_type_object_representation() double_optionalPubSubType::double_optionalPubSubType() { - setName("double_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(double_optional::getMaxCdrSerializedSize()); -#else - double_optional_max_cdr_typesize; -#endif + set_name("double_optional"); + uint32_t type_size = double_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = double_optional_max_key_cdr_typesize > 16 ? double_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = double_optional_max_key_cdr_typesize > 16 ? double_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } double_optionalPubSubType::~double_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool double_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const double_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool double_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool double_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool double_optionalPubSubType::deserialize( double_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool double_optionalPubSubType::deserialize( return true; } -std::function double_optionalPubSubType::getSerializedSizeProvider( +uint32_t double_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* double_optionalPubSubType::createData() +void* double_optionalPubSubType::create_data() { return reinterpret_cast(new double_optional()); } -void double_optionalPubSubType::deleteData( +void double_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool double_optionalPubSubType::getKey( +bool double_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + double_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool double_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool double_optionalPubSubType::getKey( const double_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), double_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || double_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void double_optionalPubSubType::register_type_object_representation() longdouble_optionalPubSubType::longdouble_optionalPubSubType() { - setName("longdouble_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(longdouble_optional::getMaxCdrSerializedSize()); -#else - longdouble_optional_max_cdr_typesize; -#endif + set_name("longdouble_optional"); + uint32_t type_size = longdouble_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = longdouble_optional_max_key_cdr_typesize > 16 ? longdouble_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = longdouble_optional_max_key_cdr_typesize > 16 ? longdouble_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } longdouble_optionalPubSubType::~longdouble_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool longdouble_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const longdouble_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool longdouble_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool longdouble_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool longdouble_optionalPubSubType::deserialize( longdouble_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool longdouble_optionalPubSubType::deserialize( return true; } -std::function longdouble_optionalPubSubType::getSerializedSizeProvider( +uint32_t longdouble_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* longdouble_optionalPubSubType::createData() +void* longdouble_optionalPubSubType::create_data() { return reinterpret_cast(new longdouble_optional()); } -void longdouble_optionalPubSubType::deleteData( +void longdouble_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool longdouble_optionalPubSubType::getKey( +bool longdouble_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + longdouble_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool longdouble_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool longdouble_optionalPubSubType::getKey( const longdouble_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), longdouble_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || longdouble_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void longdouble_optionalPubSubType::register_type_object_representation() boolean_optionalPubSubType::boolean_optionalPubSubType() { - setName("boolean_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(boolean_optional::getMaxCdrSerializedSize()); -#else - boolean_optional_max_cdr_typesize; -#endif + set_name("boolean_optional"); + uint32_t type_size = boolean_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = boolean_optional_max_key_cdr_typesize > 16 ? boolean_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = boolean_optional_max_key_cdr_typesize > 16 ? boolean_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } boolean_optionalPubSubType::~boolean_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool boolean_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const boolean_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool boolean_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool boolean_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool boolean_optionalPubSubType::deserialize( boolean_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool boolean_optionalPubSubType::deserialize( return true; } -std::function boolean_optionalPubSubType::getSerializedSizeProvider( +uint32_t boolean_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* boolean_optionalPubSubType::createData() +void* boolean_optionalPubSubType::create_data() { return reinterpret_cast(new boolean_optional()); } -void boolean_optionalPubSubType::deleteData( +void boolean_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool boolean_optionalPubSubType::getKey( +bool boolean_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + boolean_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool boolean_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool boolean_optionalPubSubType::getKey( const boolean_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), boolean_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || boolean_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void boolean_optionalPubSubType::register_type_object_representation() octet_optionalPubSubType::octet_optionalPubSubType() { - setName("octet_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(octet_optional::getMaxCdrSerializedSize()); -#else - octet_optional_max_cdr_typesize; -#endif + set_name("octet_optional"); + uint32_t type_size = octet_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = octet_optional_max_key_cdr_typesize > 16 ? octet_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = octet_optional_max_key_cdr_typesize > 16 ? octet_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } octet_optionalPubSubType::~octet_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool octet_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const octet_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool octet_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool octet_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool octet_optionalPubSubType::deserialize( octet_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool octet_optionalPubSubType::deserialize( return true; } -std::function octet_optionalPubSubType::getSerializedSizeProvider( +uint32_t octet_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* octet_optionalPubSubType::createData() +void* octet_optionalPubSubType::create_data() { return reinterpret_cast(new octet_optional()); } -void octet_optionalPubSubType::deleteData( +void octet_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool octet_optionalPubSubType::getKey( +bool octet_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + octet_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool octet_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool octet_optionalPubSubType::getKey( const octet_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), octet_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || octet_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void octet_optionalPubSubType::register_type_object_representation() char_optionalPubSubType::char_optionalPubSubType() { - setName("char_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(char_optional::getMaxCdrSerializedSize()); -#else - char_optional_max_cdr_typesize; -#endif + set_name("char_optional"); + uint32_t type_size = char_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = char_optional_max_key_cdr_typesize > 16 ? char_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = char_optional_max_key_cdr_typesize > 16 ? char_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } char_optionalPubSubType::~char_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool char_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const char_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool char_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool char_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool char_optionalPubSubType::deserialize( char_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool char_optionalPubSubType::deserialize( return true; } -std::function char_optionalPubSubType::getSerializedSizeProvider( +uint32_t char_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* char_optionalPubSubType::createData() +void* char_optionalPubSubType::create_data() { return reinterpret_cast(new char_optional()); } -void char_optionalPubSubType::deleteData( +void char_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool char_optionalPubSubType::getKey( +bool char_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + char_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool char_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool char_optionalPubSubType::getKey( const char_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), char_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || char_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void char_optionalPubSubType::register_type_object_representation() wchar_optionalPubSubType::wchar_optionalPubSubType() { - setName("wchar_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(wchar_optional::getMaxCdrSerializedSize()); -#else - wchar_optional_max_cdr_typesize; -#endif + set_name("wchar_optional"); + uint32_t type_size = wchar_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = wchar_optional_max_key_cdr_typesize > 16 ? wchar_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = wchar_optional_max_key_cdr_typesize > 16 ? wchar_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } wchar_optionalPubSubType::~wchar_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool wchar_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const wchar_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool wchar_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool wchar_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool wchar_optionalPubSubType::deserialize( wchar_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,52 +2277,62 @@ bool wchar_optionalPubSubType::deserialize( return true; } -std::function wchar_optionalPubSubType::getSerializedSizeProvider( +uint32_t wchar_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* wchar_optionalPubSubType::createData() +void* wchar_optionalPubSubType::create_data() { return reinterpret_cast(new wchar_optional()); } -void wchar_optionalPubSubType::deleteData( +void wchar_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool wchar_optionalPubSubType::getKey( +bool wchar_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + wchar_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool wchar_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2501,35 +2340,27 @@ bool wchar_optionalPubSubType::getKey( const wchar_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), wchar_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || wchar_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void wchar_optionalPubSubType::register_type_object_representation() short_align_1_optionalPubSubType::short_align_1_optionalPubSubType() { - setName("short_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(short_align_1_optional::getMaxCdrSerializedSize()); -#else - short_align_1_optional_max_cdr_typesize; -#endif + set_name("short_align_1_optional"); + uint32_t type_size = short_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = short_align_1_optional_max_key_cdr_typesize > 16 ? short_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = short_align_1_optional_max_key_cdr_typesize > 16 ? short_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } short_align_1_optionalPubSubType::~short_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool short_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool short_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool short_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool short_align_1_optionalPubSubType::deserialize( short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool short_align_1_optionalPubSubType::deserialize( return true; } -std::function short_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t short_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* short_align_1_optionalPubSubType::createData() +void* short_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new short_align_1_optional()); } -void short_align_1_optionalPubSubType::deleteData( +void short_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool short_align_1_optionalPubSubType::getKey( +bool short_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + short_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool short_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool short_align_1_optionalPubSubType::getKey( const short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), short_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || short_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void short_align_1_optionalPubSubType::register_type_object_representation() short_align_2_optionalPubSubType::short_align_2_optionalPubSubType() { - setName("short_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(short_align_2_optional::getMaxCdrSerializedSize()); -#else - short_align_2_optional_max_cdr_typesize; -#endif + set_name("short_align_2_optional"); + uint32_t type_size = short_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = short_align_2_optional_max_key_cdr_typesize > 16 ? short_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = short_align_2_optional_max_key_cdr_typesize > 16 ? short_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } short_align_2_optionalPubSubType::~short_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool short_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool short_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool short_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool short_align_2_optionalPubSubType::deserialize( short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool short_align_2_optionalPubSubType::deserialize( return true; } -std::function short_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t short_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* short_align_2_optionalPubSubType::createData() -{ - return reinterpret_cast(new short_align_2_optional()); + 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 short_align_2_optionalPubSubType::deleteData( +void* short_align_2_optionalPubSubType::create_data() +{ + return reinterpret_cast(new short_align_2_optional()); +} + +void short_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool short_align_2_optionalPubSubType::getKey( +bool short_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + short_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool short_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool short_align_2_optionalPubSubType::getKey( const short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), short_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || short_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void short_align_2_optionalPubSubType::register_type_object_representation() short_align_4_optionalPubSubType::short_align_4_optionalPubSubType() { - setName("short_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(short_align_4_optional::getMaxCdrSerializedSize()); -#else - short_align_4_optional_max_cdr_typesize; -#endif + set_name("short_align_4_optional"); + uint32_t type_size = short_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = short_align_4_optional_max_key_cdr_typesize > 16 ? short_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = short_align_4_optional_max_key_cdr_typesize > 16 ? short_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } short_align_4_optionalPubSubType::~short_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool short_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool short_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool short_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool short_align_4_optionalPubSubType::deserialize( short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool short_align_4_optionalPubSubType::deserialize( return true; } -std::function short_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t short_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* short_align_4_optionalPubSubType::createData() +void* short_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new short_align_4_optional()); } -void short_align_4_optionalPubSubType::deleteData( +void short_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool short_align_4_optionalPubSubType::getKey( +bool short_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + short_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool short_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool short_align_4_optionalPubSubType::getKey( const short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), short_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || short_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void short_align_4_optionalPubSubType::register_type_object_representation() ushort_align_1_optionalPubSubType::ushort_align_1_optionalPubSubType() { - setName("ushort_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ushort_align_1_optional::getMaxCdrSerializedSize()); -#else - ushort_align_1_optional_max_cdr_typesize; -#endif + set_name("ushort_align_1_optional"); + uint32_t type_size = ushort_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ushort_align_1_optional_max_key_cdr_typesize > 16 ? ushort_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ushort_align_1_optional_max_key_cdr_typesize > 16 ? ushort_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ushort_align_1_optionalPubSubType::~ushort_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ushort_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ushort_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool ushort_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ushort_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool ushort_align_1_optionalPubSubType::deserialize( ushort_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool ushort_align_1_optionalPubSubType::deserialize( return true; } -std::function ushort_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t ushort_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ushort_align_1_optionalPubSubType::createData() +void* ushort_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new ushort_align_1_optional()); } -void ushort_align_1_optionalPubSubType::deleteData( +void ushort_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ushort_align_1_optionalPubSubType::getKey( +bool ushort_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ushort_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ushort_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool ushort_align_1_optionalPubSubType::getKey( const ushort_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ushort_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ushort_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void ushort_align_1_optionalPubSubType::register_type_object_representation() ushort_align_2_optionalPubSubType::ushort_align_2_optionalPubSubType() { - setName("ushort_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ushort_align_2_optional::getMaxCdrSerializedSize()); -#else - ushort_align_2_optional_max_cdr_typesize; -#endif + set_name("ushort_align_2_optional"); + uint32_t type_size = ushort_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ushort_align_2_optional_max_key_cdr_typesize > 16 ? ushort_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ushort_align_2_optional_max_key_cdr_typesize > 16 ? ushort_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ushort_align_2_optionalPubSubType::~ushort_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ushort_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ushort_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool ushort_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ushort_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool ushort_align_2_optionalPubSubType::deserialize( ushort_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool ushort_align_2_optionalPubSubType::deserialize( return true; } -std::function ushort_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t ushort_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ushort_align_2_optionalPubSubType::createData() +void* ushort_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new ushort_align_2_optional()); } -void ushort_align_2_optionalPubSubType::deleteData( +void ushort_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ushort_align_2_optionalPubSubType::getKey( +bool ushort_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ushort_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ushort_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool ushort_align_2_optionalPubSubType::getKey( const ushort_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ushort_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ushort_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void ushort_align_2_optionalPubSubType::register_type_object_representation() ushort_align_4_optionalPubSubType::ushort_align_4_optionalPubSubType() { - setName("ushort_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ushort_align_4_optional::getMaxCdrSerializedSize()); -#else - ushort_align_4_optional_max_cdr_typesize; -#endif + set_name("ushort_align_4_optional"); + uint32_t type_size = ushort_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ushort_align_4_optional_max_key_cdr_typesize > 16 ? ushort_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ushort_align_4_optional_max_key_cdr_typesize > 16 ? ushort_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ushort_align_4_optionalPubSubType::~ushort_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ushort_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ushort_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool ushort_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ushort_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool ushort_align_4_optionalPubSubType::deserialize( ushort_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool ushort_align_4_optionalPubSubType::deserialize( return true; } -std::function ushort_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t ushort_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ushort_align_4_optionalPubSubType::createData() +void* ushort_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new ushort_align_4_optional()); } -void ushort_align_4_optionalPubSubType::deleteData( +void ushort_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ushort_align_4_optionalPubSubType::getKey( +bool ushort_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ushort_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ushort_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool ushort_align_4_optionalPubSubType::getKey( const ushort_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ushort_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ushort_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3700,49 +3453,42 @@ void ushort_align_4_optionalPubSubType::register_type_object_representation() long_align_1_optionalPubSubType::long_align_1_optionalPubSubType() { - setName("long_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(long_align_1_optional::getMaxCdrSerializedSize()); -#else - long_align_1_optional_max_cdr_typesize; -#endif + set_name("long_align_1_optional"); + uint32_t type_size = long_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = long_align_1_optional_max_key_cdr_typesize > 16 ? long_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = long_align_1_optional_max_key_cdr_typesize > 16 ? long_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } long_align_1_optionalPubSubType::~long_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool long_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const long_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3757,16 +3503,12 @@ bool long_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool long_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3775,18 +3517,14 @@ bool long_align_1_optionalPubSubType::deserialize( long_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3799,52 +3537,62 @@ bool long_align_1_optionalPubSubType::deserialize( return true; } -std::function long_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t long_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* long_align_1_optionalPubSubType::createData() +void* long_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new long_align_1_optional()); } -void long_align_1_optionalPubSubType::deleteData( +void long_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool long_align_1_optionalPubSubType::getKey( +bool long_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + long_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool long_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3852,35 +3600,27 @@ bool long_align_1_optionalPubSubType::getKey( const long_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), long_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || long_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3893,49 +3633,42 @@ void long_align_1_optionalPubSubType::register_type_object_representation() long_align_2_optionalPubSubType::long_align_2_optionalPubSubType() { - setName("long_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(long_align_2_optional::getMaxCdrSerializedSize()); -#else - long_align_2_optional_max_cdr_typesize; -#endif + set_name("long_align_2_optional"); + uint32_t type_size = long_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = long_align_2_optional_max_key_cdr_typesize > 16 ? long_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = long_align_2_optional_max_key_cdr_typesize > 16 ? long_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } long_align_2_optionalPubSubType::~long_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool long_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const long_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3950,16 +3683,12 @@ bool long_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool long_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3968,18 +3697,14 @@ bool long_align_2_optionalPubSubType::deserialize( long_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3992,52 +3717,62 @@ bool long_align_2_optionalPubSubType::deserialize( return true; } -std::function long_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t long_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* long_align_2_optionalPubSubType::createData() +void* long_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new long_align_2_optional()); } -void long_align_2_optionalPubSubType::deleteData( +void long_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool long_align_2_optionalPubSubType::getKey( +bool long_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + long_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool long_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4045,35 +3780,27 @@ bool long_align_2_optionalPubSubType::getKey( const long_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), long_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || long_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4086,49 +3813,42 @@ void long_align_2_optionalPubSubType::register_type_object_representation() long_align_4_optionalPubSubType::long_align_4_optionalPubSubType() { - setName("long_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(long_align_4_optional::getMaxCdrSerializedSize()); -#else - long_align_4_optional_max_cdr_typesize; -#endif + set_name("long_align_4_optional"); + uint32_t type_size = long_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = long_align_4_optional_max_key_cdr_typesize > 16 ? long_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = long_align_4_optional_max_key_cdr_typesize > 16 ? long_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } long_align_4_optionalPubSubType::~long_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool long_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const long_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4143,16 +3863,12 @@ bool long_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool long_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4161,18 +3877,14 @@ bool long_align_4_optionalPubSubType::deserialize( long_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4185,52 +3897,62 @@ bool long_align_4_optionalPubSubType::deserialize( return true; } -std::function long_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t long_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* long_align_4_optionalPubSubType::createData() +void* long_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new long_align_4_optional()); } -void long_align_4_optionalPubSubType::deleteData( +void long_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool long_align_4_optionalPubSubType::getKey( +bool long_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + long_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool long_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4238,35 +3960,27 @@ bool long_align_4_optionalPubSubType::getKey( const long_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), long_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || long_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4279,49 +3993,42 @@ void long_align_4_optionalPubSubType::register_type_object_representation() ulong_align_1_optionalPubSubType::ulong_align_1_optionalPubSubType() { - setName("ulong_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ulong_align_1_optional::getMaxCdrSerializedSize()); -#else - ulong_align_1_optional_max_cdr_typesize; -#endif + set_name("ulong_align_1_optional"); + uint32_t type_size = ulong_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ulong_align_1_optional_max_key_cdr_typesize > 16 ? ulong_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ulong_align_1_optional_max_key_cdr_typesize > 16 ? ulong_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ulong_align_1_optionalPubSubType::~ulong_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ulong_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ulong_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4336,16 +4043,12 @@ bool ulong_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ulong_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4354,18 +4057,14 @@ bool ulong_align_1_optionalPubSubType::deserialize( ulong_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4378,52 +4077,62 @@ bool ulong_align_1_optionalPubSubType::deserialize( return true; } -std::function ulong_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t ulong_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ulong_align_1_optionalPubSubType::createData() +void* ulong_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new ulong_align_1_optional()); } -void ulong_align_1_optionalPubSubType::deleteData( +void ulong_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ulong_align_1_optionalPubSubType::getKey( +bool ulong_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ulong_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ulong_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4431,35 +4140,27 @@ bool ulong_align_1_optionalPubSubType::getKey( const ulong_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ulong_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ulong_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4472,49 +4173,42 @@ void ulong_align_1_optionalPubSubType::register_type_object_representation() ulong_align_2_optionalPubSubType::ulong_align_2_optionalPubSubType() { - setName("ulong_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ulong_align_2_optional::getMaxCdrSerializedSize()); -#else - ulong_align_2_optional_max_cdr_typesize; -#endif + set_name("ulong_align_2_optional"); + uint32_t type_size = ulong_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ulong_align_2_optional_max_key_cdr_typesize > 16 ? ulong_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ulong_align_2_optional_max_key_cdr_typesize > 16 ? ulong_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ulong_align_2_optionalPubSubType::~ulong_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ulong_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ulong_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4529,16 +4223,12 @@ bool ulong_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ulong_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4547,18 +4237,14 @@ bool ulong_align_2_optionalPubSubType::deserialize( ulong_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4571,52 +4257,62 @@ bool ulong_align_2_optionalPubSubType::deserialize( return true; } -std::function ulong_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t ulong_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ulong_align_2_optionalPubSubType::createData() +void* ulong_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new ulong_align_2_optional()); } -void ulong_align_2_optionalPubSubType::deleteData( +void ulong_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ulong_align_2_optionalPubSubType::getKey( +bool ulong_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ulong_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ulong_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4624,35 +4320,27 @@ bool ulong_align_2_optionalPubSubType::getKey( const ulong_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ulong_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ulong_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4665,49 +4353,42 @@ void ulong_align_2_optionalPubSubType::register_type_object_representation() ulong_align_4_optionalPubSubType::ulong_align_4_optionalPubSubType() { - setName("ulong_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ulong_align_4_optional::getMaxCdrSerializedSize()); -#else - ulong_align_4_optional_max_cdr_typesize; -#endif + set_name("ulong_align_4_optional"); + uint32_t type_size = ulong_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ulong_align_4_optional_max_key_cdr_typesize > 16 ? ulong_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ulong_align_4_optional_max_key_cdr_typesize > 16 ? ulong_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ulong_align_4_optionalPubSubType::~ulong_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ulong_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ulong_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4722,16 +4403,12 @@ bool ulong_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ulong_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4740,18 +4417,14 @@ bool ulong_align_4_optionalPubSubType::deserialize( ulong_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4764,52 +4437,62 @@ bool ulong_align_4_optionalPubSubType::deserialize( return true; } -std::function ulong_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t ulong_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ulong_align_4_optionalPubSubType::createData() +void* ulong_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new ulong_align_4_optional()); } -void ulong_align_4_optionalPubSubType::deleteData( +void ulong_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ulong_align_4_optionalPubSubType::getKey( +bool ulong_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ulong_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ulong_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4817,35 +4500,27 @@ bool ulong_align_4_optionalPubSubType::getKey( const ulong_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ulong_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ulong_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4858,49 +4533,42 @@ void ulong_align_4_optionalPubSubType::register_type_object_representation() longlong_align_1_optionalPubSubType::longlong_align_1_optionalPubSubType() { - setName("longlong_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(longlong_align_1_optional::getMaxCdrSerializedSize()); -#else - longlong_align_1_optional_max_cdr_typesize; -#endif + set_name("longlong_align_1_optional"); + uint32_t type_size = longlong_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = longlong_align_1_optional_max_key_cdr_typesize > 16 ? longlong_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = longlong_align_1_optional_max_key_cdr_typesize > 16 ? longlong_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } longlong_align_1_optionalPubSubType::~longlong_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool longlong_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const longlong_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4915,16 +4583,12 @@ bool longlong_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool longlong_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4933,18 +4597,14 @@ bool longlong_align_1_optionalPubSubType::deserialize( longlong_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4957,52 +4617,62 @@ bool longlong_align_1_optionalPubSubType::deserialize( return true; } -std::function longlong_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t longlong_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* longlong_align_1_optionalPubSubType::createData() +void* longlong_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new longlong_align_1_optional()); } -void longlong_align_1_optionalPubSubType::deleteData( +void longlong_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool longlong_align_1_optionalPubSubType::getKey( +bool longlong_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + longlong_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool longlong_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5010,35 +4680,27 @@ bool longlong_align_1_optionalPubSubType::getKey( const longlong_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), longlong_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || longlong_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5051,49 +4713,42 @@ void longlong_align_1_optionalPubSubType::register_type_object_representation() longlong_align_2_optionalPubSubType::longlong_align_2_optionalPubSubType() { - setName("longlong_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(longlong_align_2_optional::getMaxCdrSerializedSize()); -#else - longlong_align_2_optional_max_cdr_typesize; -#endif + set_name("longlong_align_2_optional"); + uint32_t type_size = longlong_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = longlong_align_2_optional_max_key_cdr_typesize > 16 ? longlong_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = longlong_align_2_optional_max_key_cdr_typesize > 16 ? longlong_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } longlong_align_2_optionalPubSubType::~longlong_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool longlong_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const longlong_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5108,16 +4763,12 @@ bool longlong_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool longlong_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5126,18 +4777,14 @@ bool longlong_align_2_optionalPubSubType::deserialize( longlong_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5150,52 +4797,62 @@ bool longlong_align_2_optionalPubSubType::deserialize( return true; } -std::function longlong_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t longlong_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* longlong_align_2_optionalPubSubType::createData() +void* longlong_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new longlong_align_2_optional()); } -void longlong_align_2_optionalPubSubType::deleteData( +void longlong_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool longlong_align_2_optionalPubSubType::getKey( +bool longlong_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + longlong_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool longlong_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5203,35 +4860,27 @@ bool longlong_align_2_optionalPubSubType::getKey( const longlong_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), longlong_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || longlong_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5244,49 +4893,42 @@ void longlong_align_2_optionalPubSubType::register_type_object_representation() longlong_align_4_optionalPubSubType::longlong_align_4_optionalPubSubType() { - setName("longlong_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(longlong_align_4_optional::getMaxCdrSerializedSize()); -#else - longlong_align_4_optional_max_cdr_typesize; -#endif + set_name("longlong_align_4_optional"); + uint32_t type_size = longlong_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = longlong_align_4_optional_max_key_cdr_typesize > 16 ? longlong_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = longlong_align_4_optional_max_key_cdr_typesize > 16 ? longlong_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } longlong_align_4_optionalPubSubType::~longlong_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool longlong_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const longlong_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5301,16 +4943,12 @@ bool longlong_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool longlong_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5319,18 +4957,14 @@ bool longlong_align_4_optionalPubSubType::deserialize( longlong_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5343,52 +4977,62 @@ bool longlong_align_4_optionalPubSubType::deserialize( return true; } -std::function longlong_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t longlong_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* longlong_align_4_optionalPubSubType::createData() +void* longlong_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new longlong_align_4_optional()); } -void longlong_align_4_optionalPubSubType::deleteData( +void longlong_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool longlong_align_4_optionalPubSubType::getKey( +bool longlong_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + longlong_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool longlong_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5396,35 +5040,27 @@ bool longlong_align_4_optionalPubSubType::getKey( const longlong_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), longlong_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || longlong_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5437,49 +5073,42 @@ void longlong_align_4_optionalPubSubType::register_type_object_representation() ulonglong_align_1_optionalPubSubType::ulonglong_align_1_optionalPubSubType() { - setName("ulonglong_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ulonglong_align_1_optional::getMaxCdrSerializedSize()); -#else - ulonglong_align_1_optional_max_cdr_typesize; -#endif + set_name("ulonglong_align_1_optional"); + uint32_t type_size = ulonglong_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ulonglong_align_1_optional_max_key_cdr_typesize > 16 ? ulonglong_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ulonglong_align_1_optional_max_key_cdr_typesize > 16 ? ulonglong_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ulonglong_align_1_optionalPubSubType::~ulonglong_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ulonglong_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ulonglong_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5494,16 +5123,12 @@ bool ulonglong_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ulonglong_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5512,18 +5137,14 @@ bool ulonglong_align_1_optionalPubSubType::deserialize( ulonglong_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5536,52 +5157,62 @@ bool ulonglong_align_1_optionalPubSubType::deserialize( return true; } -std::function ulonglong_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t ulonglong_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ulonglong_align_1_optionalPubSubType::createData() +void* ulonglong_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new ulonglong_align_1_optional()); } -void ulonglong_align_1_optionalPubSubType::deleteData( +void ulonglong_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ulonglong_align_1_optionalPubSubType::getKey( +bool ulonglong_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ulonglong_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ulonglong_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5589,35 +5220,27 @@ bool ulonglong_align_1_optionalPubSubType::getKey( const ulonglong_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ulonglong_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ulonglong_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5630,49 +5253,42 @@ void ulonglong_align_1_optionalPubSubType::register_type_object_representation() ulonglong_align_2_optionalPubSubType::ulonglong_align_2_optionalPubSubType() { - setName("ulonglong_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ulonglong_align_2_optional::getMaxCdrSerializedSize()); -#else - ulonglong_align_2_optional_max_cdr_typesize; -#endif + set_name("ulonglong_align_2_optional"); + uint32_t type_size = ulonglong_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ulonglong_align_2_optional_max_key_cdr_typesize > 16 ? ulonglong_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ulonglong_align_2_optional_max_key_cdr_typesize > 16 ? ulonglong_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ulonglong_align_2_optionalPubSubType::~ulonglong_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ulonglong_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ulonglong_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5687,16 +5303,12 @@ bool ulonglong_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ulonglong_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5705,18 +5317,14 @@ bool ulonglong_align_2_optionalPubSubType::deserialize( ulonglong_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5729,52 +5337,62 @@ bool ulonglong_align_2_optionalPubSubType::deserialize( return true; } -std::function ulonglong_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t ulonglong_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ulonglong_align_2_optionalPubSubType::createData() +void* ulonglong_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new ulonglong_align_2_optional()); } -void ulonglong_align_2_optionalPubSubType::deleteData( +void ulonglong_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ulonglong_align_2_optionalPubSubType::getKey( +bool ulonglong_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ulonglong_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ulonglong_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5782,35 +5400,27 @@ bool ulonglong_align_2_optionalPubSubType::getKey( const ulonglong_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ulonglong_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ulonglong_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5823,49 +5433,42 @@ void ulonglong_align_2_optionalPubSubType::register_type_object_representation() ulonglong_align_4_optionalPubSubType::ulonglong_align_4_optionalPubSubType() { - setName("ulonglong_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ulonglong_align_4_optional::getMaxCdrSerializedSize()); -#else - ulonglong_align_4_optional_max_cdr_typesize; -#endif + set_name("ulonglong_align_4_optional"); + uint32_t type_size = ulonglong_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ulonglong_align_4_optional_max_key_cdr_typesize > 16 ? ulonglong_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ulonglong_align_4_optional_max_key_cdr_typesize > 16 ? ulonglong_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ulonglong_align_4_optionalPubSubType::~ulonglong_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ulonglong_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ulonglong_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5880,16 +5483,12 @@ bool ulonglong_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ulonglong_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5898,18 +5497,14 @@ bool ulonglong_align_4_optionalPubSubType::deserialize( ulonglong_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5922,52 +5517,62 @@ bool ulonglong_align_4_optionalPubSubType::deserialize( return true; } -std::function ulonglong_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t ulonglong_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ulonglong_align_4_optionalPubSubType::createData() +void* ulonglong_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new ulonglong_align_4_optional()); } -void ulonglong_align_4_optionalPubSubType::deleteData( +void ulonglong_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ulonglong_align_4_optionalPubSubType::getKey( +bool ulonglong_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ulonglong_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ulonglong_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5975,35 +5580,27 @@ bool ulonglong_align_4_optionalPubSubType::getKey( const ulonglong_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ulonglong_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ulonglong_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6016,49 +5613,42 @@ void ulonglong_align_4_optionalPubSubType::register_type_object_representation() float_align_1_optionalPubSubType::float_align_1_optionalPubSubType() { - setName("float_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(float_align_1_optional::getMaxCdrSerializedSize()); -#else - float_align_1_optional_max_cdr_typesize; -#endif + set_name("float_align_1_optional"); + uint32_t type_size = float_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = float_align_1_optional_max_key_cdr_typesize > 16 ? float_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = float_align_1_optional_max_key_cdr_typesize > 16 ? float_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } float_align_1_optionalPubSubType::~float_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool float_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const float_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6073,16 +5663,12 @@ bool float_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool float_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6091,18 +5677,14 @@ bool float_align_1_optionalPubSubType::deserialize( float_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6115,52 +5697,62 @@ bool float_align_1_optionalPubSubType::deserialize( return true; } -std::function float_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t float_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* float_align_1_optionalPubSubType::createData() +void* float_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new float_align_1_optional()); } -void float_align_1_optionalPubSubType::deleteData( +void float_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool float_align_1_optionalPubSubType::getKey( +bool float_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + float_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool float_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6168,35 +5760,27 @@ bool float_align_1_optionalPubSubType::getKey( const float_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), float_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || float_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6209,49 +5793,42 @@ void float_align_1_optionalPubSubType::register_type_object_representation() float_align_2_optionalPubSubType::float_align_2_optionalPubSubType() { - setName("float_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(float_align_2_optional::getMaxCdrSerializedSize()); -#else - float_align_2_optional_max_cdr_typesize; -#endif + set_name("float_align_2_optional"); + uint32_t type_size = float_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = float_align_2_optional_max_key_cdr_typesize > 16 ? float_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = float_align_2_optional_max_key_cdr_typesize > 16 ? float_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } float_align_2_optionalPubSubType::~float_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool float_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const float_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6266,16 +5843,12 @@ bool float_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool float_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6284,18 +5857,14 @@ bool float_align_2_optionalPubSubType::deserialize( float_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6308,52 +5877,62 @@ bool float_align_2_optionalPubSubType::deserialize( return true; } -std::function float_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t float_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* float_align_2_optionalPubSubType::createData() +void* float_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new float_align_2_optional()); } -void float_align_2_optionalPubSubType::deleteData( +void float_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool float_align_2_optionalPubSubType::getKey( +bool float_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + float_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool float_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6361,35 +5940,27 @@ bool float_align_2_optionalPubSubType::getKey( const float_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), float_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || float_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6402,49 +5973,42 @@ void float_align_2_optionalPubSubType::register_type_object_representation() float_align_4_optionalPubSubType::float_align_4_optionalPubSubType() { - setName("float_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(float_align_4_optional::getMaxCdrSerializedSize()); -#else - float_align_4_optional_max_cdr_typesize; -#endif + set_name("float_align_4_optional"); + uint32_t type_size = float_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = float_align_4_optional_max_key_cdr_typesize > 16 ? float_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = float_align_4_optional_max_key_cdr_typesize > 16 ? float_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } float_align_4_optionalPubSubType::~float_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool float_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const float_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6459,16 +6023,12 @@ bool float_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool float_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6477,18 +6037,14 @@ bool float_align_4_optionalPubSubType::deserialize( float_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6501,52 +6057,62 @@ bool float_align_4_optionalPubSubType::deserialize( return true; } -std::function float_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t float_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* float_align_4_optionalPubSubType::createData() +void* float_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new float_align_4_optional()); } -void float_align_4_optionalPubSubType::deleteData( +void float_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool float_align_4_optionalPubSubType::getKey( +bool float_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + float_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool float_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6554,35 +6120,27 @@ bool float_align_4_optionalPubSubType::getKey( const float_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), float_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || float_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6595,49 +6153,42 @@ void float_align_4_optionalPubSubType::register_type_object_representation() double_align_1_optionalPubSubType::double_align_1_optionalPubSubType() { - setName("double_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(double_align_1_optional::getMaxCdrSerializedSize()); -#else - double_align_1_optional_max_cdr_typesize; -#endif + set_name("double_align_1_optional"); + uint32_t type_size = double_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = double_align_1_optional_max_key_cdr_typesize > 16 ? double_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = double_align_1_optional_max_key_cdr_typesize > 16 ? double_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } double_align_1_optionalPubSubType::~double_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool double_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const double_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6652,16 +6203,12 @@ bool double_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool double_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6670,18 +6217,14 @@ bool double_align_1_optionalPubSubType::deserialize( double_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6694,52 +6237,62 @@ bool double_align_1_optionalPubSubType::deserialize( return true; } -std::function double_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t double_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* double_align_1_optionalPubSubType::createData() +void* double_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new double_align_1_optional()); } -void double_align_1_optionalPubSubType::deleteData( +void double_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool double_align_1_optionalPubSubType::getKey( +bool double_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + double_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool double_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6747,35 +6300,27 @@ bool double_align_1_optionalPubSubType::getKey( const double_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), double_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || double_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6788,49 +6333,42 @@ void double_align_1_optionalPubSubType::register_type_object_representation() double_align_2_optionalPubSubType::double_align_2_optionalPubSubType() { - setName("double_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(double_align_2_optional::getMaxCdrSerializedSize()); -#else - double_align_2_optional_max_cdr_typesize; -#endif + set_name("double_align_2_optional"); + uint32_t type_size = double_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = double_align_2_optional_max_key_cdr_typesize > 16 ? double_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = double_align_2_optional_max_key_cdr_typesize > 16 ? double_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } double_align_2_optionalPubSubType::~double_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool double_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const double_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6845,16 +6383,12 @@ bool double_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool double_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6863,18 +6397,14 @@ bool double_align_2_optionalPubSubType::deserialize( double_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6887,52 +6417,62 @@ bool double_align_2_optionalPubSubType::deserialize( return true; } -std::function double_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t double_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* double_align_2_optionalPubSubType::createData() +void* double_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new double_align_2_optional()); } -void double_align_2_optionalPubSubType::deleteData( +void double_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool double_align_2_optionalPubSubType::getKey( +bool double_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + double_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool double_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6940,35 +6480,27 @@ bool double_align_2_optionalPubSubType::getKey( const double_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), double_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || double_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6981,49 +6513,42 @@ void double_align_2_optionalPubSubType::register_type_object_representation() double_align_4_optionalPubSubType::double_align_4_optionalPubSubType() { - setName("double_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(double_align_4_optional::getMaxCdrSerializedSize()); -#else - double_align_4_optional_max_cdr_typesize; -#endif + set_name("double_align_4_optional"); + uint32_t type_size = double_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = double_align_4_optional_max_key_cdr_typesize > 16 ? double_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = double_align_4_optional_max_key_cdr_typesize > 16 ? double_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } double_align_4_optionalPubSubType::~double_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool double_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const double_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7038,16 +6563,12 @@ bool double_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool double_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7056,18 +6577,14 @@ bool double_align_4_optionalPubSubType::deserialize( double_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7080,52 +6597,62 @@ bool double_align_4_optionalPubSubType::deserialize( return true; } -std::function double_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t double_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* double_align_4_optionalPubSubType::createData() +void* double_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new double_align_4_optional()); } -void double_align_4_optionalPubSubType::deleteData( +void double_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool double_align_4_optionalPubSubType::getKey( +bool double_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + double_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool double_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7133,35 +6660,27 @@ bool double_align_4_optionalPubSubType::getKey( const double_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), double_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || double_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7174,49 +6693,42 @@ void double_align_4_optionalPubSubType::register_type_object_representation() longdouble_align_1_optionalPubSubType::longdouble_align_1_optionalPubSubType() { - setName("longdouble_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(longdouble_align_1_optional::getMaxCdrSerializedSize()); -#else - longdouble_align_1_optional_max_cdr_typesize; -#endif + set_name("longdouble_align_1_optional"); + uint32_t type_size = longdouble_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = longdouble_align_1_optional_max_key_cdr_typesize > 16 ? longdouble_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = longdouble_align_1_optional_max_key_cdr_typesize > 16 ? longdouble_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } longdouble_align_1_optionalPubSubType::~longdouble_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool longdouble_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const longdouble_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7231,16 +6743,12 @@ bool longdouble_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool longdouble_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7249,18 +6757,14 @@ bool longdouble_align_1_optionalPubSubType::deserialize( longdouble_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7273,52 +6777,62 @@ bool longdouble_align_1_optionalPubSubType::deserialize( return true; } -std::function longdouble_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t longdouble_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* longdouble_align_1_optionalPubSubType::createData() +void* longdouble_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new longdouble_align_1_optional()); } -void longdouble_align_1_optionalPubSubType::deleteData( +void longdouble_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool longdouble_align_1_optionalPubSubType::getKey( +bool longdouble_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + longdouble_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool longdouble_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7326,35 +6840,27 @@ bool longdouble_align_1_optionalPubSubType::getKey( const longdouble_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), longdouble_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || longdouble_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7367,49 +6873,42 @@ void longdouble_align_1_optionalPubSubType::register_type_object_representation( longdouble_align_2_optionalPubSubType::longdouble_align_2_optionalPubSubType() { - setName("longdouble_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(longdouble_align_2_optional::getMaxCdrSerializedSize()); -#else - longdouble_align_2_optional_max_cdr_typesize; -#endif + set_name("longdouble_align_2_optional"); + uint32_t type_size = longdouble_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = longdouble_align_2_optional_max_key_cdr_typesize > 16 ? longdouble_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = longdouble_align_2_optional_max_key_cdr_typesize > 16 ? longdouble_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } longdouble_align_2_optionalPubSubType::~longdouble_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool longdouble_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const longdouble_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7424,16 +6923,12 @@ bool longdouble_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool longdouble_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7442,18 +6937,14 @@ bool longdouble_align_2_optionalPubSubType::deserialize( longdouble_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7466,52 +6957,62 @@ bool longdouble_align_2_optionalPubSubType::deserialize( return true; } -std::function longdouble_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t longdouble_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* longdouble_align_2_optionalPubSubType::createData() +void* longdouble_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new longdouble_align_2_optional()); } -void longdouble_align_2_optionalPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); +void longdouble_align_2_optionalPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool longdouble_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + longdouble_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; } -bool longdouble_align_2_optionalPubSubType::getKey( +bool longdouble_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7519,35 +7020,27 @@ bool longdouble_align_2_optionalPubSubType::getKey( const longdouble_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), longdouble_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || longdouble_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7560,49 +7053,42 @@ void longdouble_align_2_optionalPubSubType::register_type_object_representation( longdouble_align_4_optionalPubSubType::longdouble_align_4_optionalPubSubType() { - setName("longdouble_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(longdouble_align_4_optional::getMaxCdrSerializedSize()); -#else - longdouble_align_4_optional_max_cdr_typesize; -#endif + set_name("longdouble_align_4_optional"); + uint32_t type_size = longdouble_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = longdouble_align_4_optional_max_key_cdr_typesize > 16 ? longdouble_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = longdouble_align_4_optional_max_key_cdr_typesize > 16 ? longdouble_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } longdouble_align_4_optionalPubSubType::~longdouble_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool longdouble_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const longdouble_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7617,16 +7103,12 @@ bool longdouble_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool longdouble_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7635,18 +7117,14 @@ bool longdouble_align_4_optionalPubSubType::deserialize( longdouble_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7659,52 +7137,62 @@ bool longdouble_align_4_optionalPubSubType::deserialize( return true; } -std::function longdouble_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t longdouble_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* longdouble_align_4_optionalPubSubType::createData() +void* longdouble_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new longdouble_align_4_optional()); } -void longdouble_align_4_optionalPubSubType::deleteData( +void longdouble_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool longdouble_align_4_optionalPubSubType::getKey( +bool longdouble_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + longdouble_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool longdouble_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7712,35 +7200,27 @@ bool longdouble_align_4_optionalPubSubType::getKey( const longdouble_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), longdouble_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || longdouble_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7753,49 +7233,42 @@ void longdouble_align_4_optionalPubSubType::register_type_object_representation( boolean_align_1_optionalPubSubType::boolean_align_1_optionalPubSubType() { - setName("boolean_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(boolean_align_1_optional::getMaxCdrSerializedSize()); -#else - boolean_align_1_optional_max_cdr_typesize; -#endif + set_name("boolean_align_1_optional"); + uint32_t type_size = boolean_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = boolean_align_1_optional_max_key_cdr_typesize > 16 ? boolean_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = boolean_align_1_optional_max_key_cdr_typesize > 16 ? boolean_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } boolean_align_1_optionalPubSubType::~boolean_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool boolean_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const boolean_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7810,16 +7283,12 @@ bool boolean_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool boolean_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7828,18 +7297,14 @@ bool boolean_align_1_optionalPubSubType::deserialize( boolean_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7852,52 +7317,62 @@ bool boolean_align_1_optionalPubSubType::deserialize( return true; } -std::function boolean_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t boolean_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* boolean_align_1_optionalPubSubType::createData() +void* boolean_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new boolean_align_1_optional()); } -void boolean_align_1_optionalPubSubType::deleteData( +void boolean_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool boolean_align_1_optionalPubSubType::getKey( +bool boolean_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + boolean_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool boolean_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7905,35 +7380,27 @@ bool boolean_align_1_optionalPubSubType::getKey( const boolean_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), boolean_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || boolean_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7946,49 +7413,42 @@ void boolean_align_1_optionalPubSubType::register_type_object_representation() boolean_align_2_optionalPubSubType::boolean_align_2_optionalPubSubType() { - setName("boolean_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(boolean_align_2_optional::getMaxCdrSerializedSize()); -#else - boolean_align_2_optional_max_cdr_typesize; -#endif + set_name("boolean_align_2_optional"); + uint32_t type_size = boolean_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = boolean_align_2_optional_max_key_cdr_typesize > 16 ? boolean_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = boolean_align_2_optional_max_key_cdr_typesize > 16 ? boolean_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } boolean_align_2_optionalPubSubType::~boolean_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool boolean_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const boolean_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8003,16 +7463,12 @@ bool boolean_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool boolean_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8021,18 +7477,14 @@ bool boolean_align_2_optionalPubSubType::deserialize( boolean_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8045,52 +7497,62 @@ bool boolean_align_2_optionalPubSubType::deserialize( return true; } -std::function boolean_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t boolean_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* boolean_align_2_optionalPubSubType::createData() +void* boolean_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new boolean_align_2_optional()); } -void boolean_align_2_optionalPubSubType::deleteData( +void boolean_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool boolean_align_2_optionalPubSubType::getKey( +bool boolean_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + boolean_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool boolean_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8098,35 +7560,27 @@ bool boolean_align_2_optionalPubSubType::getKey( const boolean_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), boolean_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || boolean_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8139,49 +7593,42 @@ void boolean_align_2_optionalPubSubType::register_type_object_representation() boolean_align_4_optionalPubSubType::boolean_align_4_optionalPubSubType() { - setName("boolean_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(boolean_align_4_optional::getMaxCdrSerializedSize()); -#else - boolean_align_4_optional_max_cdr_typesize; -#endif + set_name("boolean_align_4_optional"); + uint32_t type_size = boolean_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = boolean_align_4_optional_max_key_cdr_typesize > 16 ? boolean_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = boolean_align_4_optional_max_key_cdr_typesize > 16 ? boolean_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } boolean_align_4_optionalPubSubType::~boolean_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool boolean_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const boolean_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8196,16 +7643,12 @@ bool boolean_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool boolean_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8214,18 +7657,14 @@ bool boolean_align_4_optionalPubSubType::deserialize( boolean_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8238,52 +7677,62 @@ bool boolean_align_4_optionalPubSubType::deserialize( return true; } -std::function boolean_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t boolean_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* boolean_align_4_optionalPubSubType::createData() +void* boolean_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new boolean_align_4_optional()); } -void boolean_align_4_optionalPubSubType::deleteData( +void boolean_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool boolean_align_4_optionalPubSubType::getKey( +bool boolean_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + boolean_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool boolean_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8291,35 +7740,27 @@ bool boolean_align_4_optionalPubSubType::getKey( const boolean_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), boolean_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || boolean_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8332,49 +7773,42 @@ void boolean_align_4_optionalPubSubType::register_type_object_representation() octet_align_1_optionalPubSubType::octet_align_1_optionalPubSubType() { - setName("octet_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(octet_align_1_optional::getMaxCdrSerializedSize()); -#else - octet_align_1_optional_max_cdr_typesize; -#endif + set_name("octet_align_1_optional"); + uint32_t type_size = octet_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = octet_align_1_optional_max_key_cdr_typesize > 16 ? octet_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = octet_align_1_optional_max_key_cdr_typesize > 16 ? octet_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } octet_align_1_optionalPubSubType::~octet_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool octet_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const octet_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8389,16 +7823,12 @@ bool octet_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool octet_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8407,18 +7837,14 @@ bool octet_align_1_optionalPubSubType::deserialize( octet_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8431,52 +7857,62 @@ bool octet_align_1_optionalPubSubType::deserialize( return true; } -std::function octet_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t octet_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* octet_align_1_optionalPubSubType::createData() +void* octet_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new octet_align_1_optional()); } -void octet_align_1_optionalPubSubType::deleteData( +void octet_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool octet_align_1_optionalPubSubType::getKey( +bool octet_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + octet_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool octet_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8484,35 +7920,27 @@ bool octet_align_1_optionalPubSubType::getKey( const octet_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), octet_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || octet_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8525,49 +7953,42 @@ void octet_align_1_optionalPubSubType::register_type_object_representation() octet_align_2_optionalPubSubType::octet_align_2_optionalPubSubType() { - setName("octet_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(octet_align_2_optional::getMaxCdrSerializedSize()); -#else - octet_align_2_optional_max_cdr_typesize; -#endif + set_name("octet_align_2_optional"); + uint32_t type_size = octet_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = octet_align_2_optional_max_key_cdr_typesize > 16 ? octet_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = octet_align_2_optional_max_key_cdr_typesize > 16 ? octet_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } octet_align_2_optionalPubSubType::~octet_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool octet_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const octet_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8582,16 +8003,12 @@ bool octet_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool octet_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8600,18 +8017,14 @@ bool octet_align_2_optionalPubSubType::deserialize( octet_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8624,52 +8037,62 @@ bool octet_align_2_optionalPubSubType::deserialize( return true; } -std::function octet_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t octet_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* octet_align_2_optionalPubSubType::createData() +void* octet_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new octet_align_2_optional()); } -void octet_align_2_optionalPubSubType::deleteData( +void octet_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool octet_align_2_optionalPubSubType::getKey( +bool octet_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + octet_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool octet_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8677,35 +8100,27 @@ bool octet_align_2_optionalPubSubType::getKey( const octet_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), octet_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || octet_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8718,49 +8133,42 @@ void octet_align_2_optionalPubSubType::register_type_object_representation() octet_align_4_optionalPubSubType::octet_align_4_optionalPubSubType() { - setName("octet_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(octet_align_4_optional::getMaxCdrSerializedSize()); -#else - octet_align_4_optional_max_cdr_typesize; -#endif + set_name("octet_align_4_optional"); + uint32_t type_size = octet_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = octet_align_4_optional_max_key_cdr_typesize > 16 ? octet_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = octet_align_4_optional_max_key_cdr_typesize > 16 ? octet_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } octet_align_4_optionalPubSubType::~octet_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool octet_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const octet_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8775,16 +8183,12 @@ bool octet_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool octet_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8793,18 +8197,14 @@ bool octet_align_4_optionalPubSubType::deserialize( octet_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -8817,52 +8217,62 @@ bool octet_align_4_optionalPubSubType::deserialize( return true; } -std::function octet_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t octet_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* octet_align_4_optionalPubSubType::createData() +void* octet_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new octet_align_4_optional()); } -void octet_align_4_optionalPubSubType::deleteData( +void octet_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool octet_align_4_optionalPubSubType::getKey( +bool octet_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + octet_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool octet_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -8870,35 +8280,27 @@ bool octet_align_4_optionalPubSubType::getKey( const octet_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), octet_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || octet_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -8911,49 +8313,42 @@ void octet_align_4_optionalPubSubType::register_type_object_representation() char_align_1_optionalPubSubType::char_align_1_optionalPubSubType() { - setName("char_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(char_align_1_optional::getMaxCdrSerializedSize()); -#else - char_align_1_optional_max_cdr_typesize; -#endif + set_name("char_align_1_optional"); + uint32_t type_size = char_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = char_align_1_optional_max_key_cdr_typesize > 16 ? char_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = char_align_1_optional_max_key_cdr_typesize > 16 ? char_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } char_align_1_optionalPubSubType::~char_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool char_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const char_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -8968,16 +8363,12 @@ bool char_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool char_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -8986,18 +8377,14 @@ bool char_align_1_optionalPubSubType::deserialize( char_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9010,52 +8397,62 @@ bool char_align_1_optionalPubSubType::deserialize( return true; } -std::function char_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t char_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* char_align_1_optionalPubSubType::createData() +void* char_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new char_align_1_optional()); } -void char_align_1_optionalPubSubType::deleteData( +void char_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool char_align_1_optionalPubSubType::getKey( +bool char_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + char_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool char_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9063,35 +8460,27 @@ bool char_align_1_optionalPubSubType::getKey( const char_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), char_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || char_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9104,49 +8493,42 @@ void char_align_1_optionalPubSubType::register_type_object_representation() char_align_2_optionalPubSubType::char_align_2_optionalPubSubType() { - setName("char_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(char_align_2_optional::getMaxCdrSerializedSize()); -#else - char_align_2_optional_max_cdr_typesize; -#endif + set_name("char_align_2_optional"); + uint32_t type_size = char_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = char_align_2_optional_max_key_cdr_typesize > 16 ? char_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = char_align_2_optional_max_key_cdr_typesize > 16 ? char_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } char_align_2_optionalPubSubType::~char_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool char_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const char_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9161,16 +8543,12 @@ bool char_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool char_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9179,18 +8557,14 @@ bool char_align_2_optionalPubSubType::deserialize( char_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9203,52 +8577,62 @@ bool char_align_2_optionalPubSubType::deserialize( return true; } -std::function char_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t char_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* char_align_2_optionalPubSubType::createData() +void* char_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new char_align_2_optional()); } -void char_align_2_optionalPubSubType::deleteData( +void char_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool char_align_2_optionalPubSubType::getKey( +bool char_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + char_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool char_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9256,35 +8640,27 @@ bool char_align_2_optionalPubSubType::getKey( const char_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), char_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || char_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9297,49 +8673,42 @@ void char_align_2_optionalPubSubType::register_type_object_representation() char_align_4_optionalPubSubType::char_align_4_optionalPubSubType() { - setName("char_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(char_align_4_optional::getMaxCdrSerializedSize()); -#else - char_align_4_optional_max_cdr_typesize; -#endif + set_name("char_align_4_optional"); + uint32_t type_size = char_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = char_align_4_optional_max_key_cdr_typesize > 16 ? char_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = char_align_4_optional_max_key_cdr_typesize > 16 ? char_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } char_align_4_optionalPubSubType::~char_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool char_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const char_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9354,16 +8723,12 @@ bool char_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool char_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9372,18 +8737,14 @@ bool char_align_4_optionalPubSubType::deserialize( char_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9396,52 +8757,62 @@ bool char_align_4_optionalPubSubType::deserialize( return true; } -std::function char_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t char_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* char_align_4_optionalPubSubType::createData() +void* char_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new char_align_4_optional()); } -void char_align_4_optionalPubSubType::deleteData( +void char_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool char_align_4_optionalPubSubType::getKey( +bool char_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + char_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool char_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9449,35 +8820,27 @@ bool char_align_4_optionalPubSubType::getKey( const char_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), char_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || char_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9490,49 +8853,42 @@ void char_align_4_optionalPubSubType::register_type_object_representation() wchar_align_1_optionalPubSubType::wchar_align_1_optionalPubSubType() { - setName("wchar_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(wchar_align_1_optional::getMaxCdrSerializedSize()); -#else - wchar_align_1_optional_max_cdr_typesize; -#endif + set_name("wchar_align_1_optional"); + uint32_t type_size = wchar_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = wchar_align_1_optional_max_key_cdr_typesize > 16 ? wchar_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = wchar_align_1_optional_max_key_cdr_typesize > 16 ? wchar_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } wchar_align_1_optionalPubSubType::~wchar_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool wchar_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const wchar_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9547,16 +8903,12 @@ bool wchar_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool wchar_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9565,18 +8917,14 @@ bool wchar_align_1_optionalPubSubType::deserialize( wchar_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9589,52 +8937,62 @@ bool wchar_align_1_optionalPubSubType::deserialize( return true; } -std::function wchar_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t wchar_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* wchar_align_1_optionalPubSubType::createData() +void* wchar_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new wchar_align_1_optional()); } -void wchar_align_1_optionalPubSubType::deleteData( +void wchar_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool wchar_align_1_optionalPubSubType::getKey( +bool wchar_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + wchar_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool wchar_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9642,35 +9000,27 @@ bool wchar_align_1_optionalPubSubType::getKey( const wchar_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), wchar_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || wchar_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9683,49 +9033,42 @@ void wchar_align_1_optionalPubSubType::register_type_object_representation() wchar_align_2_optionalPubSubType::wchar_align_2_optionalPubSubType() { - setName("wchar_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(wchar_align_2_optional::getMaxCdrSerializedSize()); -#else - wchar_align_2_optional_max_cdr_typesize; -#endif + set_name("wchar_align_2_optional"); + uint32_t type_size = wchar_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = wchar_align_2_optional_max_key_cdr_typesize > 16 ? wchar_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = wchar_align_2_optional_max_key_cdr_typesize > 16 ? wchar_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } wchar_align_2_optionalPubSubType::~wchar_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool wchar_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const wchar_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9740,16 +9083,12 @@ bool wchar_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool wchar_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9758,18 +9097,14 @@ bool wchar_align_2_optionalPubSubType::deserialize( wchar_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9782,52 +9117,62 @@ bool wchar_align_2_optionalPubSubType::deserialize( return true; } -std::function wchar_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t wchar_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* wchar_align_2_optionalPubSubType::createData() +void* wchar_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new wchar_align_2_optional()); } -void wchar_align_2_optionalPubSubType::deleteData( +void wchar_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool wchar_align_2_optionalPubSubType::getKey( +bool wchar_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + wchar_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool wchar_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -9835,35 +9180,27 @@ bool wchar_align_2_optionalPubSubType::getKey( const wchar_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), wchar_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || wchar_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -9876,49 +9213,42 @@ void wchar_align_2_optionalPubSubType::register_type_object_representation() wchar_align_4_optionalPubSubType::wchar_align_4_optionalPubSubType() { - setName("wchar_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(wchar_align_4_optional::getMaxCdrSerializedSize()); -#else - wchar_align_4_optional_max_cdr_typesize; -#endif + set_name("wchar_align_4_optional"); + uint32_t type_size = wchar_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = wchar_align_4_optional_max_key_cdr_typesize > 16 ? wchar_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = wchar_align_4_optional_max_key_cdr_typesize > 16 ? wchar_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } wchar_align_4_optionalPubSubType::~wchar_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool wchar_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const wchar_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -9933,16 +9263,12 @@ bool wchar_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool wchar_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -9951,18 +9277,14 @@ bool wchar_align_4_optionalPubSubType::deserialize( wchar_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -9975,52 +9297,62 @@ bool wchar_align_4_optionalPubSubType::deserialize( return true; } -std::function wchar_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t wchar_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* wchar_align_4_optionalPubSubType::createData() +void* wchar_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new wchar_align_4_optional()); } -void wchar_align_4_optionalPubSubType::deleteData( +void wchar_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool wchar_align_4_optionalPubSubType::getKey( +bool wchar_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + wchar_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool wchar_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10028,35 +9360,27 @@ bool wchar_align_4_optionalPubSubType::getKey( const wchar_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), wchar_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || wchar_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10069,49 +9393,42 @@ void wchar_align_4_optionalPubSubType::register_type_object_representation() sequence_short_optionalPubSubType::sequence_short_optionalPubSubType() { - setName("sequence_short_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sequence_short_optional::getMaxCdrSerializedSize()); -#else - sequence_short_optional_max_cdr_typesize; -#endif + set_name("sequence_short_optional"); + uint32_t type_size = sequence_short_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = sequence_short_optional_max_key_cdr_typesize > 16 ? sequence_short_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = sequence_short_optional_max_key_cdr_typesize > 16 ? sequence_short_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } sequence_short_optionalPubSubType::~sequence_short_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool sequence_short_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const sequence_short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10126,16 +9443,12 @@ bool sequence_short_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool sequence_short_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10144,18 +9457,14 @@ bool sequence_short_optionalPubSubType::deserialize( sequence_short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10168,52 +9477,62 @@ bool sequence_short_optionalPubSubType::deserialize( return true; } -std::function sequence_short_optionalPubSubType::getSerializedSizeProvider( +uint32_t sequence_short_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* sequence_short_optionalPubSubType::createData() +void* sequence_short_optionalPubSubType::create_data() { return reinterpret_cast(new sequence_short_optional()); } -void sequence_short_optionalPubSubType::deleteData( +void sequence_short_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool sequence_short_optionalPubSubType::getKey( +bool sequence_short_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + sequence_short_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool sequence_short_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10221,35 +9540,27 @@ bool sequence_short_optionalPubSubType::getKey( const sequence_short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), sequence_short_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || sequence_short_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10262,49 +9573,42 @@ void sequence_short_optionalPubSubType::register_type_object_representation() sequence_short_align_1_optionalPubSubType::sequence_short_align_1_optionalPubSubType() { - setName("sequence_short_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sequence_short_align_1_optional::getMaxCdrSerializedSize()); -#else - sequence_short_align_1_optional_max_cdr_typesize; -#endif + set_name("sequence_short_align_1_optional"); + uint32_t type_size = sequence_short_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = sequence_short_align_1_optional_max_key_cdr_typesize > 16 ? sequence_short_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = sequence_short_align_1_optional_max_key_cdr_typesize > 16 ? sequence_short_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } sequence_short_align_1_optionalPubSubType::~sequence_short_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool sequence_short_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const sequence_short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10319,16 +9623,12 @@ bool sequence_short_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool sequence_short_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10337,18 +9637,14 @@ bool sequence_short_align_1_optionalPubSubType::deserialize( sequence_short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10361,52 +9657,62 @@ bool sequence_short_align_1_optionalPubSubType::deserialize( return true; } -std::function sequence_short_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t sequence_short_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* sequence_short_align_1_optionalPubSubType::createData() +void* sequence_short_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new sequence_short_align_1_optional()); } -void sequence_short_align_1_optionalPubSubType::deleteData( +void sequence_short_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool sequence_short_align_1_optionalPubSubType::getKey( +bool sequence_short_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + sequence_short_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool sequence_short_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10414,35 +9720,27 @@ bool sequence_short_align_1_optionalPubSubType::getKey( const sequence_short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), sequence_short_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || sequence_short_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10455,49 +9753,42 @@ void sequence_short_align_1_optionalPubSubType::register_type_object_representat sequence_short_align_2_optionalPubSubType::sequence_short_align_2_optionalPubSubType() { - setName("sequence_short_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sequence_short_align_2_optional::getMaxCdrSerializedSize()); -#else - sequence_short_align_2_optional_max_cdr_typesize; -#endif + set_name("sequence_short_align_2_optional"); + uint32_t type_size = sequence_short_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = sequence_short_align_2_optional_max_key_cdr_typesize > 16 ? sequence_short_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = sequence_short_align_2_optional_max_key_cdr_typesize > 16 ? sequence_short_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } sequence_short_align_2_optionalPubSubType::~sequence_short_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool sequence_short_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const sequence_short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10512,16 +9803,12 @@ bool sequence_short_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool sequence_short_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10530,18 +9817,14 @@ bool sequence_short_align_2_optionalPubSubType::deserialize( sequence_short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10554,52 +9837,62 @@ bool sequence_short_align_2_optionalPubSubType::deserialize( return true; } -std::function sequence_short_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t sequence_short_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* sequence_short_align_2_optionalPubSubType::createData() +void* sequence_short_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new sequence_short_align_2_optional()); } -void sequence_short_align_2_optionalPubSubType::deleteData( +void sequence_short_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool sequence_short_align_2_optionalPubSubType::getKey( +bool sequence_short_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + sequence_short_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool sequence_short_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10607,35 +9900,27 @@ bool sequence_short_align_2_optionalPubSubType::getKey( const sequence_short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), sequence_short_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || sequence_short_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10648,49 +9933,42 @@ void sequence_short_align_2_optionalPubSubType::register_type_object_representat sequence_short_align_4_optionalPubSubType::sequence_short_align_4_optionalPubSubType() { - setName("sequence_short_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sequence_short_align_4_optional::getMaxCdrSerializedSize()); -#else - sequence_short_align_4_optional_max_cdr_typesize; -#endif + set_name("sequence_short_align_4_optional"); + uint32_t type_size = sequence_short_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = sequence_short_align_4_optional_max_key_cdr_typesize > 16 ? sequence_short_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = sequence_short_align_4_optional_max_key_cdr_typesize > 16 ? sequence_short_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } sequence_short_align_4_optionalPubSubType::~sequence_short_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool sequence_short_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const sequence_short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10705,16 +9983,12 @@ bool sequence_short_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool sequence_short_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10723,18 +9997,14 @@ bool sequence_short_align_4_optionalPubSubType::deserialize( sequence_short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10747,52 +10017,62 @@ bool sequence_short_align_4_optionalPubSubType::deserialize( return true; } -std::function sequence_short_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t sequence_short_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* sequence_short_align_4_optionalPubSubType::createData() +void* sequence_short_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new sequence_short_align_4_optional()); } -void sequence_short_align_4_optionalPubSubType::deleteData( +void sequence_short_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool sequence_short_align_4_optionalPubSubType::getKey( +bool sequence_short_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + sequence_short_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool sequence_short_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10800,35 +10080,27 @@ bool sequence_short_align_4_optionalPubSubType::getKey( const sequence_short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), sequence_short_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || sequence_short_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -10841,49 +10113,42 @@ void sequence_short_align_4_optionalPubSubType::register_type_object_representat string_unbounded_optionalPubSubType::string_unbounded_optionalPubSubType() { - setName("string_unbounded_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(string_unbounded_optional::getMaxCdrSerializedSize()); -#else - string_unbounded_optional_max_cdr_typesize; -#endif + set_name("string_unbounded_optional"); + uint32_t type_size = string_unbounded_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = string_unbounded_optional_max_key_cdr_typesize > 16 ? string_unbounded_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = string_unbounded_optional_max_key_cdr_typesize > 16 ? string_unbounded_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } string_unbounded_optionalPubSubType::~string_unbounded_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool string_unbounded_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const string_unbounded_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -10898,16 +10163,12 @@ bool string_unbounded_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool string_unbounded_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -10916,18 +10177,14 @@ bool string_unbounded_optionalPubSubType::deserialize( string_unbounded_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -10940,52 +10197,62 @@ bool string_unbounded_optionalPubSubType::deserialize( return true; } -std::function string_unbounded_optionalPubSubType::getSerializedSizeProvider( +uint32_t string_unbounded_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* string_unbounded_optionalPubSubType::createData() +void* string_unbounded_optionalPubSubType::create_data() { return reinterpret_cast(new string_unbounded_optional()); } -void string_unbounded_optionalPubSubType::deleteData( +void string_unbounded_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool string_unbounded_optionalPubSubType::getKey( +bool string_unbounded_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + string_unbounded_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool string_unbounded_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -10993,35 +10260,27 @@ bool string_unbounded_optionalPubSubType::getKey( const string_unbounded_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), string_unbounded_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || string_unbounded_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11034,49 +10293,42 @@ void string_unbounded_optionalPubSubType::register_type_object_representation() string_unbounded_align_1_optionalPubSubType::string_unbounded_align_1_optionalPubSubType() { - setName("string_unbounded_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(string_unbounded_align_1_optional::getMaxCdrSerializedSize()); -#else - string_unbounded_align_1_optional_max_cdr_typesize; -#endif + set_name("string_unbounded_align_1_optional"); + uint32_t type_size = string_unbounded_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = string_unbounded_align_1_optional_max_key_cdr_typesize > 16 ? string_unbounded_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = string_unbounded_align_1_optional_max_key_cdr_typesize > 16 ? string_unbounded_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } string_unbounded_align_1_optionalPubSubType::~string_unbounded_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool string_unbounded_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const string_unbounded_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11091,16 +10343,12 @@ bool string_unbounded_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool string_unbounded_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11109,18 +10357,14 @@ bool string_unbounded_align_1_optionalPubSubType::deserialize( string_unbounded_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11133,52 +10377,62 @@ bool string_unbounded_align_1_optionalPubSubType::deserialize( return true; } -std::function string_unbounded_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t string_unbounded_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* string_unbounded_align_1_optionalPubSubType::createData() +void* string_unbounded_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new string_unbounded_align_1_optional()); } -void string_unbounded_align_1_optionalPubSubType::deleteData( +void string_unbounded_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool string_unbounded_align_1_optionalPubSubType::getKey( +bool string_unbounded_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + string_unbounded_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool string_unbounded_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11186,35 +10440,27 @@ bool string_unbounded_align_1_optionalPubSubType::getKey( const string_unbounded_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), string_unbounded_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || string_unbounded_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11227,49 +10473,42 @@ void string_unbounded_align_1_optionalPubSubType::register_type_object_represent string_unbounded_align_2_optionalPubSubType::string_unbounded_align_2_optionalPubSubType() { - setName("string_unbounded_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(string_unbounded_align_2_optional::getMaxCdrSerializedSize()); -#else - string_unbounded_align_2_optional_max_cdr_typesize; -#endif + set_name("string_unbounded_align_2_optional"); + uint32_t type_size = string_unbounded_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = string_unbounded_align_2_optional_max_key_cdr_typesize > 16 ? string_unbounded_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = string_unbounded_align_2_optional_max_key_cdr_typesize > 16 ? string_unbounded_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } string_unbounded_align_2_optionalPubSubType::~string_unbounded_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool string_unbounded_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const string_unbounded_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11284,16 +10523,12 @@ bool string_unbounded_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool string_unbounded_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11302,18 +10537,14 @@ bool string_unbounded_align_2_optionalPubSubType::deserialize( string_unbounded_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11326,52 +10557,62 @@ bool string_unbounded_align_2_optionalPubSubType::deserialize( return true; } -std::function string_unbounded_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t string_unbounded_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* string_unbounded_align_2_optionalPubSubType::createData() +void* string_unbounded_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new string_unbounded_align_2_optional()); } -void string_unbounded_align_2_optionalPubSubType::deleteData( +void string_unbounded_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool string_unbounded_align_2_optionalPubSubType::getKey( +bool string_unbounded_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + string_unbounded_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool string_unbounded_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11379,35 +10620,27 @@ bool string_unbounded_align_2_optionalPubSubType::getKey( const string_unbounded_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), string_unbounded_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || string_unbounded_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11420,49 +10653,42 @@ void string_unbounded_align_2_optionalPubSubType::register_type_object_represent string_unbounded_align_4_optionalPubSubType::string_unbounded_align_4_optionalPubSubType() { - setName("string_unbounded_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(string_unbounded_align_4_optional::getMaxCdrSerializedSize()); -#else - string_unbounded_align_4_optional_max_cdr_typesize; -#endif + set_name("string_unbounded_align_4_optional"); + uint32_t type_size = string_unbounded_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = string_unbounded_align_4_optional_max_key_cdr_typesize > 16 ? string_unbounded_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = string_unbounded_align_4_optional_max_key_cdr_typesize > 16 ? string_unbounded_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } string_unbounded_align_4_optionalPubSubType::~string_unbounded_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool string_unbounded_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const string_unbounded_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11477,16 +10703,12 @@ bool string_unbounded_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool string_unbounded_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11495,18 +10717,14 @@ bool string_unbounded_align_4_optionalPubSubType::deserialize( string_unbounded_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11519,52 +10737,62 @@ bool string_unbounded_align_4_optionalPubSubType::deserialize( return true; } -std::function string_unbounded_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t string_unbounded_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* string_unbounded_align_4_optionalPubSubType::createData() +void* string_unbounded_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new string_unbounded_align_4_optional()); } -void string_unbounded_align_4_optionalPubSubType::deleteData( +void string_unbounded_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool string_unbounded_align_4_optionalPubSubType::getKey( +bool string_unbounded_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + string_unbounded_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool string_unbounded_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11572,35 +10800,27 @@ bool string_unbounded_align_4_optionalPubSubType::getKey( const string_unbounded_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), string_unbounded_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || string_unbounded_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11613,49 +10833,42 @@ void string_unbounded_align_4_optionalPubSubType::register_type_object_represent string_bounded_optionalPubSubType::string_bounded_optionalPubSubType() { - setName("string_bounded_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(string_bounded_optional::getMaxCdrSerializedSize()); -#else - string_bounded_optional_max_cdr_typesize; -#endif + set_name("string_bounded_optional"); + uint32_t type_size = string_bounded_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = string_bounded_optional_max_key_cdr_typesize > 16 ? string_bounded_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = string_bounded_optional_max_key_cdr_typesize > 16 ? string_bounded_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } string_bounded_optionalPubSubType::~string_bounded_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool string_bounded_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const string_bounded_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11670,16 +10883,12 @@ bool string_bounded_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool string_bounded_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11688,18 +10897,14 @@ bool string_bounded_optionalPubSubType::deserialize( string_bounded_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11712,52 +10917,62 @@ bool string_bounded_optionalPubSubType::deserialize( return true; } -std::function string_bounded_optionalPubSubType::getSerializedSizeProvider( +uint32_t string_bounded_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* string_bounded_optionalPubSubType::createData() +void* string_bounded_optionalPubSubType::create_data() { return reinterpret_cast(new string_bounded_optional()); } -void string_bounded_optionalPubSubType::deleteData( +void string_bounded_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool string_bounded_optionalPubSubType::getKey( +bool string_bounded_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + string_bounded_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool string_bounded_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11765,35 +10980,27 @@ bool string_bounded_optionalPubSubType::getKey( const string_bounded_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), string_bounded_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || string_bounded_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11806,49 +11013,42 @@ void string_bounded_optionalPubSubType::register_type_object_representation() string_bounded_align_1_optionalPubSubType::string_bounded_align_1_optionalPubSubType() { - setName("string_bounded_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(string_bounded_align_1_optional::getMaxCdrSerializedSize()); -#else - string_bounded_align_1_optional_max_cdr_typesize; -#endif + set_name("string_bounded_align_1_optional"); + uint32_t type_size = string_bounded_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = string_bounded_align_1_optional_max_key_cdr_typesize > 16 ? string_bounded_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = string_bounded_align_1_optional_max_key_cdr_typesize > 16 ? string_bounded_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } string_bounded_align_1_optionalPubSubType::~string_bounded_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool string_bounded_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const string_bounded_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -11863,16 +11063,12 @@ bool string_bounded_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool string_bounded_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -11881,18 +11077,14 @@ bool string_bounded_align_1_optionalPubSubType::deserialize( string_bounded_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -11905,52 +11097,62 @@ bool string_bounded_align_1_optionalPubSubType::deserialize( return true; } -std::function string_bounded_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t string_bounded_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* string_bounded_align_1_optionalPubSubType::createData() +void* string_bounded_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new string_bounded_align_1_optional()); } -void string_bounded_align_1_optionalPubSubType::deleteData( +void string_bounded_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool string_bounded_align_1_optionalPubSubType::getKey( +bool string_bounded_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + string_bounded_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool string_bounded_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -11958,35 +11160,27 @@ bool string_bounded_align_1_optionalPubSubType::getKey( const string_bounded_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), string_bounded_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || string_bounded_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -11999,49 +11193,42 @@ void string_bounded_align_1_optionalPubSubType::register_type_object_representat string_bounded_align_2_optionalPubSubType::string_bounded_align_2_optionalPubSubType() { - setName("string_bounded_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(string_bounded_align_2_optional::getMaxCdrSerializedSize()); -#else - string_bounded_align_2_optional_max_cdr_typesize; -#endif + set_name("string_bounded_align_2_optional"); + uint32_t type_size = string_bounded_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = string_bounded_align_2_optional_max_key_cdr_typesize > 16 ? string_bounded_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = string_bounded_align_2_optional_max_key_cdr_typesize > 16 ? string_bounded_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } string_bounded_align_2_optionalPubSubType::~string_bounded_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool string_bounded_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const string_bounded_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12056,16 +11243,12 @@ bool string_bounded_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool string_bounded_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12074,18 +11257,14 @@ bool string_bounded_align_2_optionalPubSubType::deserialize( string_bounded_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12098,52 +11277,62 @@ bool string_bounded_align_2_optionalPubSubType::deserialize( return true; } -std::function string_bounded_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t string_bounded_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* string_bounded_align_2_optionalPubSubType::createData() +void* string_bounded_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new string_bounded_align_2_optional()); } -void string_bounded_align_2_optionalPubSubType::deleteData( +void string_bounded_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool string_bounded_align_2_optionalPubSubType::getKey( +bool string_bounded_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + string_bounded_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool string_bounded_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12151,35 +11340,27 @@ bool string_bounded_align_2_optionalPubSubType::getKey( const string_bounded_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), string_bounded_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || string_bounded_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12192,49 +11373,42 @@ void string_bounded_align_2_optionalPubSubType::register_type_object_representat string_bounded_align_4_optionalPubSubType::string_bounded_align_4_optionalPubSubType() { - setName("string_bounded_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(string_bounded_align_4_optional::getMaxCdrSerializedSize()); -#else - string_bounded_align_4_optional_max_cdr_typesize; -#endif + set_name("string_bounded_align_4_optional"); + uint32_t type_size = string_bounded_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = string_bounded_align_4_optional_max_key_cdr_typesize > 16 ? string_bounded_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = string_bounded_align_4_optional_max_key_cdr_typesize > 16 ? string_bounded_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } string_bounded_align_4_optionalPubSubType::~string_bounded_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool string_bounded_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const string_bounded_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12249,16 +11423,12 @@ bool string_bounded_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool string_bounded_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12267,18 +11437,14 @@ bool string_bounded_align_4_optionalPubSubType::deserialize( string_bounded_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12291,52 +11457,62 @@ bool string_bounded_align_4_optionalPubSubType::deserialize( return true; } -std::function string_bounded_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t string_bounded_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* string_bounded_align_4_optionalPubSubType::createData() +void* string_bounded_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new string_bounded_align_4_optional()); } -void string_bounded_align_4_optionalPubSubType::deleteData( +void string_bounded_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool string_bounded_align_4_optionalPubSubType::getKey( +bool string_bounded_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + string_bounded_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool string_bounded_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12344,35 +11520,27 @@ bool string_bounded_align_4_optionalPubSubType::getKey( const string_bounded_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), string_bounded_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || string_bounded_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12385,49 +11553,42 @@ void string_bounded_align_4_optionalPubSubType::register_type_object_representat map_short_optionalPubSubType::map_short_optionalPubSubType() { - setName("map_short_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(map_short_optional::getMaxCdrSerializedSize()); -#else - map_short_optional_max_cdr_typesize; -#endif + set_name("map_short_optional"); + uint32_t type_size = map_short_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = map_short_optional_max_key_cdr_typesize > 16 ? map_short_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = map_short_optional_max_key_cdr_typesize > 16 ? map_short_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } map_short_optionalPubSubType::~map_short_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool map_short_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const map_short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12442,16 +11603,12 @@ bool map_short_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool map_short_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12460,18 +11617,14 @@ bool map_short_optionalPubSubType::deserialize( map_short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12484,52 +11637,62 @@ bool map_short_optionalPubSubType::deserialize( return true; } -std::function map_short_optionalPubSubType::getSerializedSizeProvider( +uint32_t map_short_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* map_short_optionalPubSubType::createData() +void* map_short_optionalPubSubType::create_data() { return reinterpret_cast(new map_short_optional()); } -void map_short_optionalPubSubType::deleteData( +void map_short_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool map_short_optionalPubSubType::getKey( +bool map_short_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + map_short_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool map_short_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12537,35 +11700,27 @@ bool map_short_optionalPubSubType::getKey( const map_short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), map_short_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || map_short_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12578,49 +11733,42 @@ void map_short_optionalPubSubType::register_type_object_representation() map_short_align_1_optionalPubSubType::map_short_align_1_optionalPubSubType() { - setName("map_short_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(map_short_align_1_optional::getMaxCdrSerializedSize()); -#else - map_short_align_1_optional_max_cdr_typesize; -#endif + set_name("map_short_align_1_optional"); + uint32_t type_size = map_short_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = map_short_align_1_optional_max_key_cdr_typesize > 16 ? map_short_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = map_short_align_1_optional_max_key_cdr_typesize > 16 ? map_short_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } map_short_align_1_optionalPubSubType::~map_short_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool map_short_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const map_short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12635,16 +11783,12 @@ bool map_short_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool map_short_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12653,18 +11797,14 @@ bool map_short_align_1_optionalPubSubType::deserialize( map_short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12677,52 +11817,62 @@ bool map_short_align_1_optionalPubSubType::deserialize( return true; } -std::function map_short_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t map_short_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* map_short_align_1_optionalPubSubType::createData() +void* map_short_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new map_short_align_1_optional()); } -void map_short_align_1_optionalPubSubType::deleteData( +void map_short_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool map_short_align_1_optionalPubSubType::getKey( +bool map_short_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + map_short_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool map_short_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12730,35 +11880,27 @@ bool map_short_align_1_optionalPubSubType::getKey( const map_short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), map_short_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || map_short_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12771,49 +11913,42 @@ void map_short_align_1_optionalPubSubType::register_type_object_representation() map_short_align_2_optionalPubSubType::map_short_align_2_optionalPubSubType() { - setName("map_short_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(map_short_align_2_optional::getMaxCdrSerializedSize()); -#else - map_short_align_2_optional_max_cdr_typesize; -#endif + set_name("map_short_align_2_optional"); + uint32_t type_size = map_short_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = map_short_align_2_optional_max_key_cdr_typesize > 16 ? map_short_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = map_short_align_2_optional_max_key_cdr_typesize > 16 ? map_short_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } map_short_align_2_optionalPubSubType::~map_short_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool map_short_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const map_short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -12828,16 +11963,12 @@ bool map_short_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool map_short_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -12846,18 +11977,14 @@ bool map_short_align_2_optionalPubSubType::deserialize( map_short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -12870,52 +11997,62 @@ bool map_short_align_2_optionalPubSubType::deserialize( return true; } -std::function map_short_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t map_short_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* map_short_align_2_optionalPubSubType::createData() +void* map_short_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new map_short_align_2_optional()); } -void map_short_align_2_optionalPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); +void map_short_align_2_optionalPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool map_short_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + map_short_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; } -bool map_short_align_2_optionalPubSubType::getKey( +bool map_short_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -12923,35 +12060,27 @@ bool map_short_align_2_optionalPubSubType::getKey( const map_short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), map_short_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || map_short_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -12964,49 +12093,42 @@ void map_short_align_2_optionalPubSubType::register_type_object_representation() map_short_align_4_optionalPubSubType::map_short_align_4_optionalPubSubType() { - setName("map_short_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(map_short_align_4_optional::getMaxCdrSerializedSize()); -#else - map_short_align_4_optional_max_cdr_typesize; -#endif + set_name("map_short_align_4_optional"); + uint32_t type_size = map_short_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = map_short_align_4_optional_max_key_cdr_typesize > 16 ? map_short_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = map_short_align_4_optional_max_key_cdr_typesize > 16 ? map_short_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } map_short_align_4_optionalPubSubType::~map_short_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool map_short_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const map_short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13021,16 +12143,12 @@ bool map_short_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool map_short_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13039,18 +12157,14 @@ bool map_short_align_4_optionalPubSubType::deserialize( map_short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13063,52 +12177,62 @@ bool map_short_align_4_optionalPubSubType::deserialize( return true; } -std::function map_short_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t map_short_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* map_short_align_4_optionalPubSubType::createData() +void* map_short_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new map_short_align_4_optional()); } -void map_short_align_4_optionalPubSubType::deleteData( +void map_short_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool map_short_align_4_optionalPubSubType::getKey( +bool map_short_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + map_short_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool map_short_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13116,35 +12240,27 @@ bool map_short_align_4_optionalPubSubType::getKey( const map_short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), map_short_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || map_short_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13157,49 +12273,42 @@ void map_short_align_4_optionalPubSubType::register_type_object_representation() array_short_optionalPubSubType::array_short_optionalPubSubType() { - setName("array_short_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(array_short_optional::getMaxCdrSerializedSize()); -#else - array_short_optional_max_cdr_typesize; -#endif + set_name("array_short_optional"); + uint32_t type_size = array_short_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = array_short_optional_max_key_cdr_typesize > 16 ? array_short_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = array_short_optional_max_key_cdr_typesize > 16 ? array_short_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } array_short_optionalPubSubType::~array_short_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool array_short_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const array_short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13214,16 +12323,12 @@ bool array_short_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool array_short_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13232,18 +12337,14 @@ bool array_short_optionalPubSubType::deserialize( array_short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13256,52 +12357,62 @@ bool array_short_optionalPubSubType::deserialize( return true; } -std::function array_short_optionalPubSubType::getSerializedSizeProvider( +uint32_t array_short_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* array_short_optionalPubSubType::createData() +void* array_short_optionalPubSubType::create_data() { return reinterpret_cast(new array_short_optional()); } -void array_short_optionalPubSubType::deleteData( +void array_short_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool array_short_optionalPubSubType::getKey( +bool array_short_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + array_short_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool array_short_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13309,35 +12420,27 @@ bool array_short_optionalPubSubType::getKey( const array_short_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), array_short_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || array_short_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13350,49 +12453,42 @@ void array_short_optionalPubSubType::register_type_object_representation() array_short_align_1_optionalPubSubType::array_short_align_1_optionalPubSubType() { - setName("array_short_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(array_short_align_1_optional::getMaxCdrSerializedSize()); -#else - array_short_align_1_optional_max_cdr_typesize; -#endif + set_name("array_short_align_1_optional"); + uint32_t type_size = array_short_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = array_short_align_1_optional_max_key_cdr_typesize > 16 ? array_short_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = array_short_align_1_optional_max_key_cdr_typesize > 16 ? array_short_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } array_short_align_1_optionalPubSubType::~array_short_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool array_short_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const array_short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13407,16 +12503,12 @@ bool array_short_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool array_short_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13425,18 +12517,14 @@ bool array_short_align_1_optionalPubSubType::deserialize( array_short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13449,52 +12537,62 @@ bool array_short_align_1_optionalPubSubType::deserialize( return true; } -std::function array_short_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t array_short_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* array_short_align_1_optionalPubSubType::createData() +void* array_short_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new array_short_align_1_optional()); } -void array_short_align_1_optionalPubSubType::deleteData( +void array_short_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool array_short_align_1_optionalPubSubType::getKey( +bool array_short_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + array_short_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool array_short_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13502,35 +12600,27 @@ bool array_short_align_1_optionalPubSubType::getKey( const array_short_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), array_short_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || array_short_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13543,49 +12633,42 @@ void array_short_align_1_optionalPubSubType::register_type_object_representation array_short_align_2_optionalPubSubType::array_short_align_2_optionalPubSubType() { - setName("array_short_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(array_short_align_2_optional::getMaxCdrSerializedSize()); -#else - array_short_align_2_optional_max_cdr_typesize; -#endif + set_name("array_short_align_2_optional"); + uint32_t type_size = array_short_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = array_short_align_2_optional_max_key_cdr_typesize > 16 ? array_short_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = array_short_align_2_optional_max_key_cdr_typesize > 16 ? array_short_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } array_short_align_2_optionalPubSubType::~array_short_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool array_short_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const array_short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13600,16 +12683,12 @@ bool array_short_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool array_short_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13618,18 +12697,14 @@ bool array_short_align_2_optionalPubSubType::deserialize( array_short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13642,52 +12717,62 @@ bool array_short_align_2_optionalPubSubType::deserialize( return true; } -std::function array_short_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t array_short_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* array_short_align_2_optionalPubSubType::createData() +void* array_short_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new array_short_align_2_optional()); } -void array_short_align_2_optionalPubSubType::deleteData( +void array_short_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool array_short_align_2_optionalPubSubType::getKey( +bool array_short_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + array_short_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool array_short_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13695,35 +12780,27 @@ bool array_short_align_2_optionalPubSubType::getKey( const array_short_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), array_short_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || array_short_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13736,49 +12813,42 @@ void array_short_align_2_optionalPubSubType::register_type_object_representation array_short_align_4_optionalPubSubType::array_short_align_4_optionalPubSubType() { - setName("array_short_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(array_short_align_4_optional::getMaxCdrSerializedSize()); -#else - array_short_align_4_optional_max_cdr_typesize; -#endif + set_name("array_short_align_4_optional"); + uint32_t type_size = array_short_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = array_short_align_4_optional_max_key_cdr_typesize > 16 ? array_short_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = array_short_align_4_optional_max_key_cdr_typesize > 16 ? array_short_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } array_short_align_4_optionalPubSubType::~array_short_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool array_short_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const array_short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13793,16 +12863,12 @@ bool array_short_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool array_short_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -13811,18 +12877,14 @@ bool array_short_align_4_optionalPubSubType::deserialize( array_short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -13835,52 +12897,62 @@ bool array_short_align_4_optionalPubSubType::deserialize( return true; } -std::function array_short_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t array_short_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* array_short_align_4_optionalPubSubType::createData() +void* array_short_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new array_short_align_4_optional()); } -void array_short_align_4_optionalPubSubType::deleteData( +void array_short_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool array_short_align_4_optionalPubSubType::getKey( +bool array_short_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + array_short_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool array_short_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -13888,35 +12960,27 @@ bool array_short_align_4_optionalPubSubType::getKey( const array_short_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), array_short_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || array_short_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -13929,49 +12993,42 @@ void array_short_align_4_optionalPubSubType::register_type_object_representation struct_optionalPubSubType::struct_optionalPubSubType() { - setName("struct_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(struct_optional::getMaxCdrSerializedSize()); -#else - struct_optional_max_cdr_typesize; -#endif + set_name("struct_optional"); + uint32_t type_size = struct_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = struct_optional_max_key_cdr_typesize > 16 ? struct_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = struct_optional_max_key_cdr_typesize > 16 ? struct_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } struct_optionalPubSubType::~struct_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool struct_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const struct_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -13986,16 +13043,12 @@ bool struct_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool struct_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14004,18 +13057,14 @@ bool struct_optionalPubSubType::deserialize( struct_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14028,52 +13077,62 @@ bool struct_optionalPubSubType::deserialize( return true; } -std::function struct_optionalPubSubType::getSerializedSizeProvider( +uint32_t struct_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* struct_optionalPubSubType::createData() +void* struct_optionalPubSubType::create_data() { return reinterpret_cast(new struct_optional()); } -void struct_optionalPubSubType::deleteData( +void struct_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool struct_optionalPubSubType::getKey( +bool struct_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + struct_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool struct_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14081,35 +13140,27 @@ bool struct_optionalPubSubType::getKey( const struct_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), struct_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || struct_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14122,49 +13173,42 @@ void struct_optionalPubSubType::register_type_object_representation() struct_align_1_optionalPubSubType::struct_align_1_optionalPubSubType() { - setName("struct_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(struct_align_1_optional::getMaxCdrSerializedSize()); -#else - struct_align_1_optional_max_cdr_typesize; -#endif + set_name("struct_align_1_optional"); + uint32_t type_size = struct_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = struct_align_1_optional_max_key_cdr_typesize > 16 ? struct_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = struct_align_1_optional_max_key_cdr_typesize > 16 ? struct_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } struct_align_1_optionalPubSubType::~struct_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool struct_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const struct_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14179,16 +13223,12 @@ bool struct_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool struct_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14197,18 +13237,14 @@ bool struct_align_1_optionalPubSubType::deserialize( struct_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14221,52 +13257,62 @@ bool struct_align_1_optionalPubSubType::deserialize( return true; } -std::function struct_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t struct_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* struct_align_1_optionalPubSubType::createData() +void* struct_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new struct_align_1_optional()); } -void struct_align_1_optionalPubSubType::deleteData( +void struct_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool struct_align_1_optionalPubSubType::getKey( +bool struct_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + struct_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool struct_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14274,35 +13320,27 @@ bool struct_align_1_optionalPubSubType::getKey( const struct_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), struct_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || struct_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14315,49 +13353,42 @@ void struct_align_1_optionalPubSubType::register_type_object_representation() struct_align_2_optionalPubSubType::struct_align_2_optionalPubSubType() { - setName("struct_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(struct_align_2_optional::getMaxCdrSerializedSize()); -#else - struct_align_2_optional_max_cdr_typesize; -#endif + set_name("struct_align_2_optional"); + uint32_t type_size = struct_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = struct_align_2_optional_max_key_cdr_typesize > 16 ? struct_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = struct_align_2_optional_max_key_cdr_typesize > 16 ? struct_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } struct_align_2_optionalPubSubType::~struct_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool struct_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const struct_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14372,16 +13403,12 @@ bool struct_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool struct_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14390,18 +13417,14 @@ bool struct_align_2_optionalPubSubType::deserialize( struct_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14414,52 +13437,62 @@ bool struct_align_2_optionalPubSubType::deserialize( return true; } -std::function struct_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t struct_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* struct_align_2_optionalPubSubType::createData() +void* struct_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new struct_align_2_optional()); } -void struct_align_2_optionalPubSubType::deleteData( +void struct_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool struct_align_2_optionalPubSubType::getKey( +bool struct_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + struct_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool struct_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14467,35 +13500,27 @@ bool struct_align_2_optionalPubSubType::getKey( const struct_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), struct_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || struct_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14508,49 +13533,42 @@ void struct_align_2_optionalPubSubType::register_type_object_representation() struct_align_4_optionalPubSubType::struct_align_4_optionalPubSubType() { - setName("struct_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(struct_align_4_optional::getMaxCdrSerializedSize()); -#else - struct_align_4_optional_max_cdr_typesize; -#endif + set_name("struct_align_4_optional"); + uint32_t type_size = struct_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = struct_align_4_optional_max_key_cdr_typesize > 16 ? struct_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = struct_align_4_optional_max_key_cdr_typesize > 16 ? struct_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } struct_align_4_optionalPubSubType::~struct_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool struct_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const struct_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14565,16 +13583,12 @@ bool struct_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool struct_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14583,18 +13597,14 @@ bool struct_align_4_optionalPubSubType::deserialize( struct_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14607,52 +13617,62 @@ bool struct_align_4_optionalPubSubType::deserialize( return true; } -std::function struct_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t struct_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* struct_align_4_optionalPubSubType::createData() +void* struct_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new struct_align_4_optional()); } -void struct_align_4_optionalPubSubType::deleteData( +void struct_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool struct_align_4_optionalPubSubType::getKey( +bool struct_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + struct_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool struct_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14660,35 +13680,27 @@ bool struct_align_4_optionalPubSubType::getKey( const struct_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), struct_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || struct_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14701,49 +13713,42 @@ void struct_align_4_optionalPubSubType::register_type_object_representation() InnerStructOptionalPubSubType::InnerStructOptionalPubSubType() { - setName("InnerStructOptional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(InnerStructOptional::getMaxCdrSerializedSize()); -#else - InnerStructOptional_max_cdr_typesize; -#endif + set_name("InnerStructOptional"); + uint32_t type_size = InnerStructOptional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = InnerStructOptional_max_key_cdr_typesize > 16 ? InnerStructOptional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = InnerStructOptional_max_key_cdr_typesize > 16 ? InnerStructOptional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } InnerStructOptionalPubSubType::~InnerStructOptionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool InnerStructOptionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const InnerStructOptional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14758,16 +13763,12 @@ bool InnerStructOptionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool InnerStructOptionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14776,18 +13777,14 @@ bool InnerStructOptionalPubSubType::deserialize( InnerStructOptional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14800,52 +13797,62 @@ bool InnerStructOptionalPubSubType::deserialize( return true; } -std::function InnerStructOptionalPubSubType::getSerializedSizeProvider( +uint32_t InnerStructOptionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* InnerStructOptionalPubSubType::createData() +void* InnerStructOptionalPubSubType::create_data() { return reinterpret_cast(new InnerStructOptional()); } -void InnerStructOptionalPubSubType::deleteData( +void InnerStructOptionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool InnerStructOptionalPubSubType::getKey( +bool InnerStructOptionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + InnerStructOptional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool InnerStructOptionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -14853,35 +13860,27 @@ bool InnerStructOptionalPubSubType::getKey( const InnerStructOptional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), InnerStructOptional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || InnerStructOptional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -14894,49 +13893,42 @@ void InnerStructOptionalPubSubType::register_type_object_representation() opt_struct_optionalPubSubType::opt_struct_optionalPubSubType() { - setName("opt_struct_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(opt_struct_optional::getMaxCdrSerializedSize()); -#else - opt_struct_optional_max_cdr_typesize; -#endif + set_name("opt_struct_optional"); + uint32_t type_size = opt_struct_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = opt_struct_optional_max_key_cdr_typesize > 16 ? opt_struct_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = opt_struct_optional_max_key_cdr_typesize > 16 ? opt_struct_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } opt_struct_optionalPubSubType::~opt_struct_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool opt_struct_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const opt_struct_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -14951,16 +13943,12 @@ bool opt_struct_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool opt_struct_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -14969,18 +13957,14 @@ bool opt_struct_optionalPubSubType::deserialize( opt_struct_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -14993,52 +13977,62 @@ bool opt_struct_optionalPubSubType::deserialize( return true; } -std::function opt_struct_optionalPubSubType::getSerializedSizeProvider( +uint32_t opt_struct_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* opt_struct_optionalPubSubType::createData() +void* opt_struct_optionalPubSubType::create_data() { return reinterpret_cast(new opt_struct_optional()); } -void opt_struct_optionalPubSubType::deleteData( +void opt_struct_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool opt_struct_optionalPubSubType::getKey( +bool opt_struct_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + opt_struct_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool opt_struct_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15046,35 +14040,27 @@ bool opt_struct_optionalPubSubType::getKey( const opt_struct_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), opt_struct_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || opt_struct_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15087,49 +14073,42 @@ void opt_struct_optionalPubSubType::register_type_object_representation() opt_struct_align_1_optionalPubSubType::opt_struct_align_1_optionalPubSubType() { - setName("opt_struct_align_1_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(opt_struct_align_1_optional::getMaxCdrSerializedSize()); -#else - opt_struct_align_1_optional_max_cdr_typesize; -#endif + set_name("opt_struct_align_1_optional"); + uint32_t type_size = opt_struct_align_1_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = opt_struct_align_1_optional_max_key_cdr_typesize > 16 ? opt_struct_align_1_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = opt_struct_align_1_optional_max_key_cdr_typesize > 16 ? opt_struct_align_1_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } opt_struct_align_1_optionalPubSubType::~opt_struct_align_1_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool opt_struct_align_1_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const opt_struct_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15144,16 +14123,12 @@ bool opt_struct_align_1_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool opt_struct_align_1_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15162,18 +14137,14 @@ bool opt_struct_align_1_optionalPubSubType::deserialize( opt_struct_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15186,52 +14157,62 @@ bool opt_struct_align_1_optionalPubSubType::deserialize( return true; } -std::function opt_struct_align_1_optionalPubSubType::getSerializedSizeProvider( +uint32_t opt_struct_align_1_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* opt_struct_align_1_optionalPubSubType::createData() +void* opt_struct_align_1_optionalPubSubType::create_data() { return reinterpret_cast(new opt_struct_align_1_optional()); } -void opt_struct_align_1_optionalPubSubType::deleteData( +void opt_struct_align_1_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool opt_struct_align_1_optionalPubSubType::getKey( +bool opt_struct_align_1_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + opt_struct_align_1_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool opt_struct_align_1_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15239,35 +14220,27 @@ bool opt_struct_align_1_optionalPubSubType::getKey( const opt_struct_align_1_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), opt_struct_align_1_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || opt_struct_align_1_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15280,49 +14253,42 @@ void opt_struct_align_1_optionalPubSubType::register_type_object_representation( opt_struct_align_2_optionalPubSubType::opt_struct_align_2_optionalPubSubType() { - setName("opt_struct_align_2_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(opt_struct_align_2_optional::getMaxCdrSerializedSize()); -#else - opt_struct_align_2_optional_max_cdr_typesize; -#endif + set_name("opt_struct_align_2_optional"); + uint32_t type_size = opt_struct_align_2_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = opt_struct_align_2_optional_max_key_cdr_typesize > 16 ? opt_struct_align_2_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = opt_struct_align_2_optional_max_key_cdr_typesize > 16 ? opt_struct_align_2_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } opt_struct_align_2_optionalPubSubType::~opt_struct_align_2_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool opt_struct_align_2_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const opt_struct_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15337,16 +14303,12 @@ bool opt_struct_align_2_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool opt_struct_align_2_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15355,18 +14317,14 @@ bool opt_struct_align_2_optionalPubSubType::deserialize( opt_struct_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15379,52 +14337,62 @@ bool opt_struct_align_2_optionalPubSubType::deserialize( return true; } -std::function opt_struct_align_2_optionalPubSubType::getSerializedSizeProvider( +uint32_t opt_struct_align_2_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* opt_struct_align_2_optionalPubSubType::createData() +void* opt_struct_align_2_optionalPubSubType::create_data() { return reinterpret_cast(new opt_struct_align_2_optional()); } -void opt_struct_align_2_optionalPubSubType::deleteData( +void opt_struct_align_2_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool opt_struct_align_2_optionalPubSubType::getKey( +bool opt_struct_align_2_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + opt_struct_align_2_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool opt_struct_align_2_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15432,35 +14400,27 @@ bool opt_struct_align_2_optionalPubSubType::getKey( const opt_struct_align_2_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), opt_struct_align_2_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || opt_struct_align_2_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -15473,49 +14433,42 @@ void opt_struct_align_2_optionalPubSubType::register_type_object_representation( opt_struct_align_4_optionalPubSubType::opt_struct_align_4_optionalPubSubType() { - setName("opt_struct_align_4_optional"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(opt_struct_align_4_optional::getMaxCdrSerializedSize()); -#else - opt_struct_align_4_optional_max_cdr_typesize; -#endif + set_name("opt_struct_align_4_optional"); + uint32_t type_size = opt_struct_align_4_optional_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = opt_struct_align_4_optional_max_key_cdr_typesize > 16 ? opt_struct_align_4_optional_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = opt_struct_align_4_optional_max_key_cdr_typesize > 16 ? opt_struct_align_4_optional_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } opt_struct_align_4_optionalPubSubType::~opt_struct_align_4_optionalPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool opt_struct_align_4_optionalPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const opt_struct_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -15530,16 +14483,12 @@ bool opt_struct_align_4_optionalPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool opt_struct_align_4_optionalPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -15548,18 +14497,14 @@ bool opt_struct_align_4_optionalPubSubType::deserialize( opt_struct_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -15572,52 +14517,62 @@ bool opt_struct_align_4_optionalPubSubType::deserialize( return true; } -std::function opt_struct_align_4_optionalPubSubType::getSerializedSizeProvider( +uint32_t opt_struct_align_4_optionalPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* opt_struct_align_4_optionalPubSubType::createData() +void* opt_struct_align_4_optionalPubSubType::create_data() { return reinterpret_cast(new opt_struct_align_4_optional()); } -void opt_struct_align_4_optionalPubSubType::deleteData( +void opt_struct_align_4_optionalPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool opt_struct_align_4_optionalPubSubType::getKey( +bool opt_struct_align_4_optionalPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + opt_struct_align_4_optional data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool opt_struct_align_4_optionalPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -15625,35 +14580,27 @@ bool opt_struct_align_4_optionalPubSubType::getKey( const opt_struct_align_4_optional* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), opt_struct_align_4_optional_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || opt_struct_align_4_optional_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/optionalPubSubTypes.hpp b/test/dds-types-test/optionalPubSubTypes.hpp index 6adef3dac91..ae477d9dd90 100644 --- a/test/dds-types-test/optionalPubSubTypes.hpp +++ b/test/dds-types-test/optionalPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated optional is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class short_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class short_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class short_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class ushort_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class ushort_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class ushort_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -237,38 +217,30 @@ class long_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -283,10 +255,6 @@ class long_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,8 +275,10 @@ class long_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -328,38 +298,30 @@ class ulong_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -374,10 +336,6 @@ class ulong_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -398,8 +356,10 @@ class ulong_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -419,38 +379,30 @@ class longlong_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -465,10 +417,6 @@ class longlong_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -489,8 +437,10 @@ class longlong_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -510,38 +460,30 @@ class ulonglong_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -556,10 +498,6 @@ class ulonglong_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -580,8 +518,10 @@ class ulonglong_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -601,38 +541,30 @@ class float_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -647,10 +579,6 @@ class float_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -671,8 +599,10 @@ class float_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -692,38 +622,30 @@ class double_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -738,10 +660,6 @@ class double_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -762,8 +680,10 @@ class double_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -783,38 +703,30 @@ class longdouble_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -829,10 +741,6 @@ class longdouble_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -853,8 +761,10 @@ class longdouble_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -874,38 +784,30 @@ class boolean_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -920,10 +822,6 @@ class boolean_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -944,8 +842,10 @@ class boolean_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -965,38 +865,30 @@ class octet_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1011,10 +903,6 @@ class octet_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1035,8 +923,10 @@ class octet_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1056,38 +946,30 @@ class char_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1102,10 +984,6 @@ class char_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1126,8 +1004,10 @@ class char_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1147,38 +1027,30 @@ class wchar_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1193,10 +1065,6 @@ class wchar_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1217,8 +1085,10 @@ class wchar_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1238,38 +1108,30 @@ class short_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1284,10 +1146,6 @@ class short_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1308,8 +1166,10 @@ class short_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1329,38 +1189,30 @@ class short_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1375,10 +1227,6 @@ class short_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1399,8 +1247,10 @@ class short_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1420,38 +1270,30 @@ class short_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1466,10 +1308,6 @@ class short_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1490,8 +1328,10 @@ class short_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1511,38 +1351,30 @@ class ushort_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1557,10 +1389,6 @@ class ushort_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1581,8 +1409,10 @@ class ushort_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1602,38 +1432,30 @@ class ushort_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1648,10 +1470,6 @@ class ushort_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1672,8 +1490,10 @@ class ushort_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1693,38 +1513,30 @@ class ushort_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1739,10 +1551,6 @@ class ushort_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1763,8 +1571,10 @@ class ushort_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1784,38 +1594,30 @@ class long_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1830,10 +1632,6 @@ class long_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1854,8 +1652,10 @@ class long_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1875,38 +1675,30 @@ class long_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1921,10 +1713,6 @@ class long_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1945,8 +1733,10 @@ class long_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1966,38 +1756,30 @@ class long_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2012,10 +1794,6 @@ class long_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2036,8 +1814,10 @@ class long_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2057,38 +1837,30 @@ class ulong_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2103,10 +1875,6 @@ class ulong_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2127,8 +1895,10 @@ class ulong_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2148,38 +1918,30 @@ class ulong_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2194,10 +1956,6 @@ class ulong_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2218,8 +1976,10 @@ class ulong_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2239,38 +1999,30 @@ class ulong_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2285,10 +2037,6 @@ class ulong_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2309,8 +2057,10 @@ class ulong_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2330,38 +2080,30 @@ class longlong_align_1_optionalPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2376,10 +2118,6 @@ class longlong_align_1_optionalPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2400,8 +2138,10 @@ class longlong_align_1_optionalPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2421,38 +2161,30 @@ class longlong_align_2_optionalPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2467,10 +2199,6 @@ class longlong_align_2_optionalPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2491,8 +2219,10 @@ class longlong_align_2_optionalPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2512,38 +2242,30 @@ class longlong_align_4_optionalPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2558,10 +2280,6 @@ class longlong_align_4_optionalPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2582,8 +2300,10 @@ class longlong_align_4_optionalPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2603,38 +2323,30 @@ class ulonglong_align_1_optionalPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2649,10 +2361,6 @@ class ulonglong_align_1_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2673,8 +2381,10 @@ class ulonglong_align_1_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2694,38 +2404,30 @@ class ulonglong_align_2_optionalPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2740,10 +2442,6 @@ class ulonglong_align_2_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2764,8 +2462,10 @@ class ulonglong_align_2_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2785,38 +2485,30 @@ class ulonglong_align_4_optionalPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2831,10 +2523,6 @@ class ulonglong_align_4_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2855,8 +2543,10 @@ class ulonglong_align_4_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2876,38 +2566,30 @@ class float_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2922,10 +2604,6 @@ class float_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2946,8 +2624,10 @@ class float_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2967,38 +2647,30 @@ class float_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3013,10 +2685,6 @@ class float_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3037,8 +2705,10 @@ class float_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3058,38 +2728,30 @@ class float_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3104,10 +2766,6 @@ class float_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3128,8 +2786,10 @@ class float_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3149,38 +2809,30 @@ class double_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3195,10 +2847,6 @@ class double_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3219,8 +2867,10 @@ class double_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3240,38 +2890,30 @@ class double_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3286,10 +2928,6 @@ class double_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3310,8 +2948,10 @@ class double_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3331,38 +2971,30 @@ class double_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3377,10 +3009,6 @@ class double_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3401,8 +3029,10 @@ class double_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3422,38 +3052,30 @@ class longdouble_align_1_optionalPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3468,10 +3090,6 @@ class longdouble_align_1_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3492,8 +3110,10 @@ class longdouble_align_1_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3513,38 +3133,30 @@ class longdouble_align_2_optionalPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3559,10 +3171,6 @@ class longdouble_align_2_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3583,8 +3191,10 @@ class longdouble_align_2_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3604,38 +3214,30 @@ class longdouble_align_4_optionalPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3650,10 +3252,6 @@ class longdouble_align_4_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3674,8 +3272,10 @@ class longdouble_align_4_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3695,38 +3295,30 @@ class boolean_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3741,10 +3333,6 @@ class boolean_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3765,8 +3353,10 @@ class boolean_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3786,38 +3376,30 @@ class boolean_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3832,10 +3414,6 @@ class boolean_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3856,8 +3434,10 @@ class boolean_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3877,38 +3457,30 @@ class boolean_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3923,10 +3495,6 @@ class boolean_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3947,8 +3515,10 @@ class boolean_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3968,38 +3538,30 @@ class octet_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4014,10 +3576,6 @@ class octet_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4038,8 +3596,10 @@ class octet_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4059,38 +3619,30 @@ class octet_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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 std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport bool deserialize( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4105,10 +3657,6 @@ class octet_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4129,8 +3677,10 @@ class octet_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4150,38 +3700,30 @@ class octet_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4196,10 +3738,6 @@ class octet_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4220,8 +3758,10 @@ class octet_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4241,38 +3781,30 @@ class char_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4287,10 +3819,6 @@ class char_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4311,8 +3839,10 @@ class char_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4332,38 +3862,30 @@ class char_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4378,10 +3900,6 @@ class char_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4402,8 +3920,10 @@ class char_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4423,38 +3943,30 @@ class char_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4469,10 +3981,6 @@ class char_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4493,8 +4001,10 @@ class char_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4514,38 +4024,30 @@ class wchar_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4560,10 +4062,6 @@ class wchar_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4584,8 +4082,10 @@ class wchar_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4605,38 +4105,30 @@ class wchar_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4651,10 +4143,6 @@ class wchar_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4675,8 +4163,10 @@ class wchar_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4696,38 +4186,30 @@ class wchar_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4742,10 +4224,6 @@ class wchar_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4766,8 +4244,10 @@ class wchar_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4787,38 +4267,30 @@ class sequence_short_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4833,10 +4305,6 @@ class sequence_short_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4857,8 +4325,10 @@ class sequence_short_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4878,38 +4348,30 @@ class sequence_short_align_1_optionalPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -4924,10 +4386,6 @@ class sequence_short_align_1_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -4948,8 +4406,10 @@ class sequence_short_align_1_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -4969,38 +4429,30 @@ class sequence_short_align_2_optionalPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5015,10 +4467,6 @@ class sequence_short_align_2_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5039,8 +4487,10 @@ class sequence_short_align_2_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5060,38 +4510,30 @@ class sequence_short_align_4_optionalPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5106,10 +4548,6 @@ class sequence_short_align_4_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5130,8 +4568,10 @@ class sequence_short_align_4_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5151,38 +4591,30 @@ class string_unbounded_optionalPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5197,10 +4629,6 @@ class string_unbounded_optionalPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5221,8 +4649,10 @@ class string_unbounded_optionalPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5242,38 +4672,30 @@ class string_unbounded_align_1_optionalPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5288,10 +4710,6 @@ class string_unbounded_align_1_optionalPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5312,8 +4730,10 @@ class string_unbounded_align_1_optionalPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5333,38 +4753,30 @@ class string_unbounded_align_2_optionalPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5379,10 +4791,6 @@ class string_unbounded_align_2_optionalPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5403,8 +4811,10 @@ class string_unbounded_align_2_optionalPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5424,38 +4834,30 @@ class string_unbounded_align_4_optionalPubSubType : public eprosima::fastdds::dd eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5470,10 +4872,6 @@ class string_unbounded_align_4_optionalPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5494,8 +4892,10 @@ class string_unbounded_align_4_optionalPubSubType : public eprosima::fastdds::dd #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5515,38 +4915,30 @@ class string_bounded_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5561,10 +4953,6 @@ class string_bounded_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5585,8 +4973,10 @@ class string_bounded_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5606,38 +4996,30 @@ class string_bounded_align_1_optionalPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5652,10 +5034,6 @@ class string_bounded_align_1_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5676,8 +5054,10 @@ class string_bounded_align_1_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5697,38 +5077,30 @@ class string_bounded_align_2_optionalPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5743,10 +5115,6 @@ class string_bounded_align_2_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5767,8 +5135,10 @@ class string_bounded_align_2_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5788,38 +5158,30 @@ class string_bounded_align_4_optionalPubSubType : public eprosima::fastdds::dds: eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5834,10 +5196,6 @@ class string_bounded_align_4_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5858,8 +5216,10 @@ class string_bounded_align_4_optionalPubSubType : public eprosima::fastdds::dds: #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5879,38 +5239,30 @@ class map_short_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -5925,10 +5277,6 @@ class map_short_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -5949,8 +5297,10 @@ class map_short_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -5970,38 +5320,30 @@ class map_short_align_1_optionalPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6016,10 +5358,6 @@ class map_short_align_1_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6040,8 +5378,10 @@ class map_short_align_1_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6061,38 +5401,30 @@ class map_short_align_2_optionalPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6107,10 +5439,6 @@ class map_short_align_2_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6131,8 +5459,10 @@ class map_short_align_2_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6152,38 +5482,30 @@ class map_short_align_4_optionalPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6198,10 +5520,6 @@ class map_short_align_4_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6222,8 +5540,10 @@ class map_short_align_4_optionalPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6243,38 +5563,30 @@ class array_short_optionalPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6289,10 +5601,6 @@ class array_short_optionalPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6313,8 +5621,10 @@ class array_short_optionalPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6334,38 +5644,30 @@ class array_short_align_1_optionalPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6380,10 +5682,6 @@ class array_short_align_1_optionalPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6404,8 +5702,10 @@ class array_short_align_1_optionalPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6425,38 +5725,30 @@ class array_short_align_2_optionalPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6471,10 +5763,6 @@ class array_short_align_2_optionalPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6495,8 +5783,10 @@ class array_short_align_2_optionalPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6516,38 +5806,30 @@ class array_short_align_4_optionalPubSubType : public eprosima::fastdds::dds::To eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6562,10 +5844,6 @@ class array_short_align_4_optionalPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6586,8 +5864,10 @@ class array_short_align_4_optionalPubSubType : public eprosima::fastdds::dds::To #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6607,38 +5887,30 @@ class struct_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6653,10 +5925,6 @@ class struct_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6677,8 +5945,10 @@ class struct_optionalPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6698,38 +5968,30 @@ class struct_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6744,10 +6006,6 @@ class struct_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6768,8 +6026,10 @@ class struct_align_1_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6789,38 +6049,30 @@ class struct_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6835,10 +6087,6 @@ class struct_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6859,8 +6107,10 @@ class struct_align_2_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6880,38 +6130,30 @@ class struct_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -6926,10 +6168,6 @@ class struct_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -6950,8 +6188,10 @@ class struct_align_4_optionalPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -6971,38 +6211,30 @@ class InnerStructOptionalPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7017,10 +6249,6 @@ class InnerStructOptionalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7041,8 +6269,10 @@ class InnerStructOptionalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7062,38 +6292,30 @@ class opt_struct_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7108,10 +6330,6 @@ class opt_struct_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7132,8 +6350,10 @@ class opt_struct_optionalPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7153,38 +6373,30 @@ class opt_struct_align_1_optionalPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7199,10 +6411,6 @@ class opt_struct_align_1_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7223,8 +6431,10 @@ class opt_struct_align_1_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7244,38 +6454,30 @@ class opt_struct_align_2_optionalPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7290,10 +6492,6 @@ class opt_struct_align_2_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7314,8 +6512,10 @@ class opt_struct_align_2_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -7335,38 +6535,30 @@ class opt_struct_align_4_optionalPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -7381,10 +6573,6 @@ class opt_struct_align_4_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -7405,8 +6593,10 @@ class opt_struct_align_4_optionalPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/primitivesPubSubTypes.cxx b/test/dds-types-test/primitivesPubSubTypes.cxx index 67da733d761..d8073957bb7 100644 --- a/test/dds-types-test/primitivesPubSubTypes.cxx +++ b/test/dds-types-test/primitivesPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; ShortStructPubSubType::ShortStructPubSubType() { - setName("ShortStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ShortStruct::getMaxCdrSerializedSize()); -#else - ShortStruct_max_cdr_typesize; -#endif + set_name("ShortStruct"); + uint32_t type_size = ShortStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ShortStruct_max_key_cdr_typesize > 16 ? ShortStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ShortStruct_max_key_cdr_typesize > 16 ? ShortStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ShortStructPubSubType::~ShortStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ShortStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool ShortStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ShortStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool ShortStructPubSubType::deserialize( ShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool ShortStructPubSubType::deserialize( return true; } -std::function ShortStructPubSubType::getSerializedSizeProvider( +uint32_t ShortStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ShortStructPubSubType::createData() + 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* ShortStructPubSubType::create_data() { return reinterpret_cast(new ShortStruct()); } -void ShortStructPubSubType::deleteData( +void ShortStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ShortStructPubSubType::getKey( +bool ShortStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ShortStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ShortStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool ShortStructPubSubType::getKey( const ShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ShortStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ShortStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void ShortStructPubSubType::register_type_object_representation() UShortStructPubSubType::UShortStructPubSubType() { - setName("UShortStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UShortStruct::getMaxCdrSerializedSize()); -#else - UShortStruct_max_cdr_typesize; -#endif + set_name("UShortStruct"); + uint32_t type_size = UShortStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UShortStruct_max_key_cdr_typesize > 16 ? UShortStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UShortStruct_max_key_cdr_typesize > 16 ? UShortStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UShortStructPubSubType::~UShortStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UShortStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool UShortStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UShortStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool UShortStructPubSubType::deserialize( UShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool UShortStructPubSubType::deserialize( return true; } -std::function UShortStructPubSubType::getSerializedSizeProvider( +uint32_t UShortStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UShortStructPubSubType::createData() + 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* UShortStructPubSubType::create_data() { return reinterpret_cast(new UShortStruct()); } -void UShortStructPubSubType::deleteData( +void UShortStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UShortStructPubSubType::getKey( +bool UShortStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UShortStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UShortStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool UShortStructPubSubType::getKey( const UShortStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UShortStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UShortStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void UShortStructPubSubType::register_type_object_representation() LongStructPubSubType::LongStructPubSubType() { - setName("LongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(LongStruct::getMaxCdrSerializedSize()); -#else - LongStruct_max_cdr_typesize; -#endif + set_name("LongStruct"); + uint32_t type_size = LongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = LongStruct_max_key_cdr_typesize > 16 ? LongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = LongStruct_max_key_cdr_typesize > 16 ? LongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } LongStructPubSubType::~LongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool LongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const LongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool LongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool LongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool LongStructPubSubType::deserialize( LongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool LongStructPubSubType::deserialize( return true; } -std::function LongStructPubSubType::getSerializedSizeProvider( +uint32_t LongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* LongStructPubSubType::createData() + 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* LongStructPubSubType::create_data() { return reinterpret_cast(new LongStruct()); } -void LongStructPubSubType::deleteData( +void LongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool LongStructPubSubType::getKey( +bool LongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + LongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool LongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool LongStructPubSubType::getKey( const LongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), LongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || LongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void LongStructPubSubType::register_type_object_representation() ULongStructPubSubType::ULongStructPubSubType() { - setName("ULongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ULongStruct::getMaxCdrSerializedSize()); -#else - ULongStruct_max_cdr_typesize; -#endif + set_name("ULongStruct"); + uint32_t type_size = ULongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ULongStruct_max_key_cdr_typesize > 16 ? ULongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ULongStruct_max_key_cdr_typesize > 16 ? ULongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ULongStructPubSubType::~ULongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ULongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool ULongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ULongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool ULongStructPubSubType::deserialize( ULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool ULongStructPubSubType::deserialize( return true; } -std::function ULongStructPubSubType::getSerializedSizeProvider( +uint32_t ULongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ULongStructPubSubType::createData() + 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* ULongStructPubSubType::create_data() { return reinterpret_cast(new ULongStruct()); } -void ULongStructPubSubType::deleteData( +void ULongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ULongStructPubSubType::getKey( +bool ULongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ULongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ULongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool ULongStructPubSubType::getKey( const ULongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ULongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ULongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void ULongStructPubSubType::register_type_object_representation() LongLongStructPubSubType::LongLongStructPubSubType() { - setName("LongLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(LongLongStruct::getMaxCdrSerializedSize()); -#else - LongLongStruct_max_cdr_typesize; -#endif + set_name("LongLongStruct"); + uint32_t type_size = LongLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = LongLongStruct_max_key_cdr_typesize > 16 ? LongLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = LongLongStruct_max_key_cdr_typesize > 16 ? LongLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } LongLongStructPubSubType::~LongLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool LongLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const LongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool LongLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool LongLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool LongLongStructPubSubType::deserialize( LongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool LongLongStructPubSubType::deserialize( return true; } -std::function LongLongStructPubSubType::getSerializedSizeProvider( +uint32_t LongLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* LongLongStructPubSubType::createData() + 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* LongLongStructPubSubType::create_data() { return reinterpret_cast(new LongLongStruct()); } -void LongLongStructPubSubType::deleteData( +void LongLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool LongLongStructPubSubType::getKey( +bool LongLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + LongLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool LongLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool LongLongStructPubSubType::getKey( const LongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), LongLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || LongLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void LongLongStructPubSubType::register_type_object_representation() ULongLongStructPubSubType::ULongLongStructPubSubType() { - setName("ULongLongStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ULongLongStruct::getMaxCdrSerializedSize()); -#else - ULongLongStruct_max_cdr_typesize; -#endif + set_name("ULongLongStruct"); + uint32_t type_size = ULongLongStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ULongLongStruct_max_key_cdr_typesize > 16 ? ULongLongStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ULongLongStruct_max_key_cdr_typesize > 16 ? ULongLongStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ULongLongStructPubSubType::~ULongLongStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ULongLongStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool ULongLongStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ULongLongStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool ULongLongStructPubSubType::deserialize( ULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool ULongLongStructPubSubType::deserialize( return true; } -std::function ULongLongStructPubSubType::getSerializedSizeProvider( +uint32_t ULongLongStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ULongLongStructPubSubType::createData() + 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* ULongLongStructPubSubType::create_data() { return reinterpret_cast(new ULongLongStruct()); } -void ULongLongStructPubSubType::deleteData( +void ULongLongStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ULongLongStructPubSubType::getKey( +bool ULongLongStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ULongLongStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ULongLongStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool ULongLongStructPubSubType::getKey( const ULongLongStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ULongLongStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ULongLongStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void ULongLongStructPubSubType::register_type_object_representation() FloatStructPubSubType::FloatStructPubSubType() { - setName("FloatStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FloatStruct::getMaxCdrSerializedSize()); -#else - FloatStruct_max_cdr_typesize; -#endif + set_name("FloatStruct"); + uint32_t type_size = FloatStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FloatStruct_max_key_cdr_typesize > 16 ? FloatStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FloatStruct_max_key_cdr_typesize > 16 ? FloatStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FloatStructPubSubType::~FloatStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FloatStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool FloatStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FloatStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool FloatStructPubSubType::deserialize( FloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool FloatStructPubSubType::deserialize( return true; } -std::function FloatStructPubSubType::getSerializedSizeProvider( +uint32_t FloatStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FloatStructPubSubType::createData() + 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* FloatStructPubSubType::create_data() { return reinterpret_cast(new FloatStruct()); } -void FloatStructPubSubType::deleteData( +void FloatStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FloatStructPubSubType::getKey( +bool FloatStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FloatStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FloatStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool FloatStructPubSubType::getKey( const FloatStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FloatStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FloatStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void FloatStructPubSubType::register_type_object_representation() DoubleStructPubSubType::DoubleStructPubSubType() { - setName("DoubleStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DoubleStruct::getMaxCdrSerializedSize()); -#else - DoubleStruct_max_cdr_typesize; -#endif + set_name("DoubleStruct"); + uint32_t type_size = DoubleStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DoubleStruct_max_key_cdr_typesize > 16 ? DoubleStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = DoubleStruct_max_key_cdr_typesize > 16 ? DoubleStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } DoubleStructPubSubType::~DoubleStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool DoubleStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const DoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool DoubleStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool DoubleStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool DoubleStructPubSubType::deserialize( DoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool DoubleStructPubSubType::deserialize( return true; } -std::function DoubleStructPubSubType::getSerializedSizeProvider( +uint32_t DoubleStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DoubleStructPubSubType::createData() + 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* DoubleStructPubSubType::create_data() { return reinterpret_cast(new DoubleStruct()); } -void DoubleStructPubSubType::deleteData( +void DoubleStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool DoubleStructPubSubType::getKey( +bool DoubleStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + DoubleStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool DoubleStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool DoubleStructPubSubType::getKey( const DoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), DoubleStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || DoubleStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void DoubleStructPubSubType::register_type_object_representation() LongDoubleStructPubSubType::LongDoubleStructPubSubType() { - setName("LongDoubleStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(LongDoubleStruct::getMaxCdrSerializedSize()); -#else - LongDoubleStruct_max_cdr_typesize; -#endif + set_name("LongDoubleStruct"); + uint32_t type_size = LongDoubleStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = LongDoubleStruct_max_key_cdr_typesize > 16 ? LongDoubleStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = LongDoubleStruct_max_key_cdr_typesize > 16 ? LongDoubleStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } LongDoubleStructPubSubType::~LongDoubleStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool LongDoubleStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const LongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool LongDoubleStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool LongDoubleStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool LongDoubleStructPubSubType::deserialize( LongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool LongDoubleStructPubSubType::deserialize( return true; } -std::function LongDoubleStructPubSubType::getSerializedSizeProvider( +uint32_t LongDoubleStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* LongDoubleStructPubSubType::createData() + 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* LongDoubleStructPubSubType::create_data() { return reinterpret_cast(new LongDoubleStruct()); } -void LongDoubleStructPubSubType::deleteData( +void LongDoubleStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool LongDoubleStructPubSubType::getKey( +bool LongDoubleStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + LongDoubleStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool LongDoubleStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool LongDoubleStructPubSubType::getKey( const LongDoubleStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), LongDoubleStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || LongDoubleStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void LongDoubleStructPubSubType::register_type_object_representation() BooleanStructPubSubType::BooleanStructPubSubType() { - setName("BooleanStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BooleanStruct::getMaxCdrSerializedSize()); -#else - BooleanStruct_max_cdr_typesize; -#endif + set_name("BooleanStruct"); + uint32_t type_size = BooleanStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BooleanStruct_max_key_cdr_typesize > 16 ? BooleanStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BooleanStruct_max_key_cdr_typesize > 16 ? BooleanStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BooleanStructPubSubType::~BooleanStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BooleanStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool BooleanStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BooleanStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool BooleanStructPubSubType::deserialize( BooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool BooleanStructPubSubType::deserialize( return true; } -std::function BooleanStructPubSubType::getSerializedSizeProvider( +uint32_t BooleanStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* BooleanStructPubSubType::createData() + 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* BooleanStructPubSubType::create_data() { return reinterpret_cast(new BooleanStruct()); } -void BooleanStructPubSubType::deleteData( +void BooleanStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BooleanStructPubSubType::getKey( +bool BooleanStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BooleanStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BooleanStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool BooleanStructPubSubType::getKey( const BooleanStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BooleanStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BooleanStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void BooleanStructPubSubType::register_type_object_representation() OctetStructPubSubType::OctetStructPubSubType() { - setName("OctetStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(OctetStruct::getMaxCdrSerializedSize()); -#else - OctetStruct_max_cdr_typesize; -#endif + set_name("OctetStruct"); + uint32_t type_size = OctetStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = OctetStruct_max_key_cdr_typesize > 16 ? OctetStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = OctetStruct_max_key_cdr_typesize > 16 ? OctetStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } OctetStructPubSubType::~OctetStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool OctetStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const OctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool OctetStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool OctetStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool OctetStructPubSubType::deserialize( OctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool OctetStructPubSubType::deserialize( return true; } -std::function OctetStructPubSubType::getSerializedSizeProvider( +uint32_t OctetStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* OctetStructPubSubType::createData() + 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* OctetStructPubSubType::create_data() { return reinterpret_cast(new OctetStruct()); } -void OctetStructPubSubType::deleteData( +void OctetStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool OctetStructPubSubType::getKey( +bool OctetStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + OctetStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool OctetStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool OctetStructPubSubType::getKey( const OctetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), OctetStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || OctetStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void OctetStructPubSubType::register_type_object_representation() CharStructPubSubType::CharStructPubSubType() { - setName("CharStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(CharStruct::getMaxCdrSerializedSize()); -#else - CharStruct_max_cdr_typesize; -#endif + set_name("CharStruct"); + uint32_t type_size = CharStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = CharStruct_max_key_cdr_typesize > 16 ? CharStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = CharStruct_max_key_cdr_typesize > 16 ? CharStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } CharStructPubSubType::~CharStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool CharStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const CharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool CharStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool CharStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool CharStructPubSubType::deserialize( CharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool CharStructPubSubType::deserialize( return true; } -std::function CharStructPubSubType::getSerializedSizeProvider( +uint32_t CharStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* CharStructPubSubType::createData() + 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* CharStructPubSubType::create_data() { return reinterpret_cast(new CharStruct()); } -void CharStructPubSubType::deleteData( +void CharStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool CharStructPubSubType::getKey( +bool CharStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + CharStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool CharStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool CharStructPubSubType::getKey( const CharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), CharStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || CharStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void CharStructPubSubType::register_type_object_representation() WCharStructPubSubType::WCharStructPubSubType() { - setName("WCharStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(WCharStruct::getMaxCdrSerializedSize()); -#else - WCharStruct_max_cdr_typesize; -#endif + set_name("WCharStruct"); + uint32_t type_size = WCharStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = WCharStruct_max_key_cdr_typesize > 16 ? WCharStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = WCharStruct_max_key_cdr_typesize > 16 ? WCharStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } WCharStructPubSubType::~WCharStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool WCharStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const WCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool WCharStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool WCharStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool WCharStructPubSubType::deserialize( WCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,52 +2277,62 @@ bool WCharStructPubSubType::deserialize( return true; } -std::function WCharStructPubSubType::getSerializedSizeProvider( +uint32_t WCharStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* WCharStructPubSubType::createData() + 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* WCharStructPubSubType::create_data() { return reinterpret_cast(new WCharStruct()); } -void WCharStructPubSubType::deleteData( +void WCharStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool WCharStructPubSubType::getKey( +bool WCharStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + WCharStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool WCharStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2501,35 +2340,27 @@ bool WCharStructPubSubType::getKey( const WCharStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), WCharStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || WCharStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void WCharStructPubSubType::register_type_object_representation() Int8StructPubSubType::Int8StructPubSubType() { - setName("Int8Struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Int8Struct::getMaxCdrSerializedSize()); -#else - Int8Struct_max_cdr_typesize; -#endif + set_name("Int8Struct"); + uint32_t type_size = Int8Struct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Int8Struct_max_key_cdr_typesize > 16 ? Int8Struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Int8Struct_max_key_cdr_typesize > 16 ? Int8Struct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Int8StructPubSubType::~Int8StructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Int8StructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Int8Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool Int8StructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Int8StructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool Int8StructPubSubType::deserialize( Int8Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool Int8StructPubSubType::deserialize( return true; } -std::function Int8StructPubSubType::getSerializedSizeProvider( +uint32_t Int8StructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* Int8StructPubSubType::createData() + 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* Int8StructPubSubType::create_data() { return reinterpret_cast(new Int8Struct()); } -void Int8StructPubSubType::deleteData( +void Int8StructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool Int8StructPubSubType::getKey( +bool Int8StructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Int8Struct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool Int8StructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool Int8StructPubSubType::getKey( const Int8Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Int8Struct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Int8Struct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void Int8StructPubSubType::register_type_object_representation() Uint8StructPubSubType::Uint8StructPubSubType() { - setName("Uint8Struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Uint8Struct::getMaxCdrSerializedSize()); -#else - Uint8Struct_max_cdr_typesize; -#endif + set_name("Uint8Struct"); + uint32_t type_size = Uint8Struct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Uint8Struct_max_key_cdr_typesize > 16 ? Uint8Struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Uint8Struct_max_key_cdr_typesize > 16 ? Uint8Struct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Uint8StructPubSubType::~Uint8StructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Uint8StructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Uint8Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool Uint8StructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Uint8StructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool Uint8StructPubSubType::deserialize( Uint8Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool Uint8StructPubSubType::deserialize( return true; } -std::function Uint8StructPubSubType::getSerializedSizeProvider( +uint32_t Uint8StructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* Uint8StructPubSubType::createData() + 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* Uint8StructPubSubType::create_data() { return reinterpret_cast(new Uint8Struct()); } -void Uint8StructPubSubType::deleteData( +void Uint8StructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool Uint8StructPubSubType::getKey( +bool Uint8StructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Uint8Struct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool Uint8StructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool Uint8StructPubSubType::getKey( const Uint8Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Uint8Struct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Uint8Struct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void Uint8StructPubSubType::register_type_object_representation() Int16StructPubSubType::Int16StructPubSubType() { - setName("Int16Struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Int16Struct::getMaxCdrSerializedSize()); -#else - Int16Struct_max_cdr_typesize; -#endif + set_name("Int16Struct"); + uint32_t type_size = Int16Struct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Int16Struct_max_key_cdr_typesize > 16 ? Int16Struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Int16Struct_max_key_cdr_typesize > 16 ? Int16Struct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Int16StructPubSubType::~Int16StructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Int16StructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Int16Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool Int16StructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Int16StructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool Int16StructPubSubType::deserialize( Int16Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool Int16StructPubSubType::deserialize( return true; } -std::function Int16StructPubSubType::getSerializedSizeProvider( +uint32_t Int16StructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* Int16StructPubSubType::createData() + 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* Int16StructPubSubType::create_data() { return reinterpret_cast(new Int16Struct()); } -void Int16StructPubSubType::deleteData( +void Int16StructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool Int16StructPubSubType::getKey( +bool Int16StructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Int16Struct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool Int16StructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool Int16StructPubSubType::getKey( const Int16Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Int16Struct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Int16Struct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void Int16StructPubSubType::register_type_object_representation() Uint16StructPubSubType::Uint16StructPubSubType() { - setName("Uint16Struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Uint16Struct::getMaxCdrSerializedSize()); -#else - Uint16Struct_max_cdr_typesize; -#endif + set_name("Uint16Struct"); + uint32_t type_size = Uint16Struct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Uint16Struct_max_key_cdr_typesize > 16 ? Uint16Struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Uint16Struct_max_key_cdr_typesize > 16 ? Uint16Struct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Uint16StructPubSubType::~Uint16StructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Uint16StructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Uint16Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool Uint16StructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Uint16StructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool Uint16StructPubSubType::deserialize( Uint16Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool Uint16StructPubSubType::deserialize( return true; } -std::function Uint16StructPubSubType::getSerializedSizeProvider( +uint32_t Uint16StructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* Uint16StructPubSubType::createData() + 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* Uint16StructPubSubType::create_data() { return reinterpret_cast(new Uint16Struct()); } -void Uint16StructPubSubType::deleteData( +void Uint16StructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool Uint16StructPubSubType::getKey( +bool Uint16StructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Uint16Struct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool Uint16StructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool Uint16StructPubSubType::getKey( const Uint16Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Uint16Struct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Uint16Struct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void Uint16StructPubSubType::register_type_object_representation() Int32StructPubSubType::Int32StructPubSubType() { - setName("Int32Struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Int32Struct::getMaxCdrSerializedSize()); -#else - Int32Struct_max_cdr_typesize; -#endif + set_name("Int32Struct"); + uint32_t type_size = Int32Struct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Int32Struct_max_key_cdr_typesize > 16 ? Int32Struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Int32Struct_max_key_cdr_typesize > 16 ? Int32Struct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Int32StructPubSubType::~Int32StructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Int32StructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Int32Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool Int32StructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Int32StructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool Int32StructPubSubType::deserialize( Int32Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool Int32StructPubSubType::deserialize( return true; } -std::function Int32StructPubSubType::getSerializedSizeProvider( +uint32_t Int32StructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* Int32StructPubSubType::createData() + 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* Int32StructPubSubType::create_data() { return reinterpret_cast(new Int32Struct()); } -void Int32StructPubSubType::deleteData( +void Int32StructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool Int32StructPubSubType::getKey( +bool Int32StructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Int32Struct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool Int32StructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool Int32StructPubSubType::getKey( const Int32Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Int32Struct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Int32Struct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void Int32StructPubSubType::register_type_object_representation() Uint32StructPubSubType::Uint32StructPubSubType() { - setName("Uint32Struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Uint32Struct::getMaxCdrSerializedSize()); -#else - Uint32Struct_max_cdr_typesize; -#endif + set_name("Uint32Struct"); + uint32_t type_size = Uint32Struct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Uint32Struct_max_key_cdr_typesize > 16 ? Uint32Struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Uint32Struct_max_key_cdr_typesize > 16 ? Uint32Struct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Uint32StructPubSubType::~Uint32StructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Uint32StructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Uint32Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool Uint32StructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Uint32StructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool Uint32StructPubSubType::deserialize( Uint32Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool Uint32StructPubSubType::deserialize( return true; } -std::function Uint32StructPubSubType::getSerializedSizeProvider( +uint32_t Uint32StructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* Uint32StructPubSubType::createData() + 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* Uint32StructPubSubType::create_data() { return reinterpret_cast(new Uint32Struct()); } -void Uint32StructPubSubType::deleteData( +void Uint32StructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool Uint32StructPubSubType::getKey( +bool Uint32StructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Uint32Struct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool Uint32StructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool Uint32StructPubSubType::getKey( const Uint32Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Uint32Struct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Uint32Struct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3700,49 +3453,42 @@ void Uint32StructPubSubType::register_type_object_representation() Int64StructPubSubType::Int64StructPubSubType() { - setName("Int64Struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Int64Struct::getMaxCdrSerializedSize()); -#else - Int64Struct_max_cdr_typesize; -#endif + set_name("Int64Struct"); + uint32_t type_size = Int64Struct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Int64Struct_max_key_cdr_typesize > 16 ? Int64Struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Int64Struct_max_key_cdr_typesize > 16 ? Int64Struct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Int64StructPubSubType::~Int64StructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Int64StructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Int64Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3757,16 +3503,12 @@ bool Int64StructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Int64StructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3775,18 +3517,14 @@ bool Int64StructPubSubType::deserialize( Int64Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3799,52 +3537,62 @@ bool Int64StructPubSubType::deserialize( return true; } -std::function Int64StructPubSubType::getSerializedSizeProvider( +uint32_t Int64StructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* Int64StructPubSubType::createData() + 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* Int64StructPubSubType::create_data() { return reinterpret_cast(new Int64Struct()); } -void Int64StructPubSubType::deleteData( +void Int64StructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool Int64StructPubSubType::getKey( +bool Int64StructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Int64Struct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool Int64StructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3852,35 +3600,27 @@ bool Int64StructPubSubType::getKey( const Int64Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Int64Struct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Int64Struct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3893,49 +3633,42 @@ void Int64StructPubSubType::register_type_object_representation() Uint64StructPubSubType::Uint64StructPubSubType() { - setName("Uint64Struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Uint64Struct::getMaxCdrSerializedSize()); -#else - Uint64Struct_max_cdr_typesize; -#endif + set_name("Uint64Struct"); + uint32_t type_size = Uint64Struct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Uint64Struct_max_key_cdr_typesize > 16 ? Uint64Struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Uint64Struct_max_key_cdr_typesize > 16 ? Uint64Struct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } Uint64StructPubSubType::~Uint64StructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool Uint64StructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Uint64Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3950,16 +3683,12 @@ bool Uint64StructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool Uint64StructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3968,18 +3697,14 @@ bool Uint64StructPubSubType::deserialize( Uint64Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3992,52 +3717,62 @@ bool Uint64StructPubSubType::deserialize( return true; } -std::function Uint64StructPubSubType::getSerializedSizeProvider( +uint32_t Uint64StructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* Uint64StructPubSubType::createData() + 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* Uint64StructPubSubType::create_data() { return reinterpret_cast(new Uint64Struct()); } -void Uint64StructPubSubType::deleteData( +void Uint64StructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool Uint64StructPubSubType::getKey( +bool Uint64StructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Uint64Struct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool Uint64StructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4045,35 +3780,27 @@ bool Uint64StructPubSubType::getKey( const Uint64Struct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Uint64Struct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Uint64Struct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/primitivesPubSubTypes.hpp b/test/dds-types-test/primitivesPubSubTypes.hpp index af517f9d0f5..064216d2982 100644 --- a/test/dds-types-test/primitivesPubSubTypes.hpp +++ b/test/dds-types-test/primitivesPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "primitives.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated primitives is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class ShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class ShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class ShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -145,38 +135,30 @@ class UShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -191,10 +173,6 @@ class UShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,8 +193,10 @@ class UShortStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -236,38 +216,30 @@ class LongStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -282,10 +254,6 @@ class LongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -306,8 +274,10 @@ class LongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -327,38 +297,30 @@ class ULongStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -373,10 +335,6 @@ class ULongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -397,8 +355,10 @@ class ULongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -418,38 +378,30 @@ class LongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -464,10 +416,6 @@ class LongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -488,8 +436,10 @@ class LongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -509,38 +459,30 @@ class ULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -555,10 +497,6 @@ class ULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -579,8 +517,10 @@ class ULongLongStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -600,38 +540,30 @@ class FloatStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -646,10 +578,6 @@ class FloatStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -670,8 +598,10 @@ class FloatStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -691,38 +621,30 @@ class DoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -737,10 +659,6 @@ class DoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -761,8 +679,10 @@ class DoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -782,38 +702,30 @@ class LongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -828,10 +740,6 @@ class LongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -852,8 +760,10 @@ class LongDoubleStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -873,38 +783,30 @@ class BooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -919,10 +821,6 @@ class BooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -943,8 +841,10 @@ class BooleanStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -964,38 +864,30 @@ class OctetStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1010,10 +902,6 @@ class OctetStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1034,8 +922,10 @@ class OctetStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1055,38 +945,30 @@ class CharStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1101,10 +983,6 @@ class CharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1125,8 +1003,10 @@ class CharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1146,38 +1026,30 @@ class WCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1192,10 +1064,6 @@ class WCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1216,8 +1084,10 @@ class WCharStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1237,38 +1107,30 @@ class Int8StructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1283,10 +1145,6 @@ class Int8StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1307,8 +1165,10 @@ class Int8StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1328,38 +1188,30 @@ class Uint8StructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1374,10 +1226,6 @@ class Uint8StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1398,8 +1246,10 @@ class Uint8StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1419,38 +1269,30 @@ class Int16StructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1465,10 +1307,6 @@ class Int16StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1489,8 +1327,10 @@ class Int16StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1510,38 +1350,30 @@ class Uint16StructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1556,10 +1388,6 @@ class Uint16StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1580,8 +1408,10 @@ class Uint16StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1601,38 +1431,30 @@ class Int32StructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1647,10 +1469,6 @@ class Int32StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1671,8 +1489,10 @@ class Int32StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1692,38 +1512,30 @@ class Uint32StructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1738,10 +1550,6 @@ class Uint32StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1762,8 +1570,10 @@ class Uint32StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1783,38 +1593,30 @@ class Int64StructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1829,10 +1631,6 @@ class Int64StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1853,8 +1651,10 @@ class Int64StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1874,38 +1674,30 @@ class Uint64StructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1920,10 +1712,6 @@ class Uint64StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1944,8 +1732,10 @@ class Uint64StructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/relative_path_includePubSubTypes.cxx b/test/dds-types-test/relative_path_includePubSubTypes.cxx index 98eb2c99806..ad38c2ca1ec 100644 --- a/test/dds-types-test/relative_path_includePubSubTypes.cxx +++ b/test/dds-types-test/relative_path_includePubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; RelativePathIncludeStructPubSubType::RelativePathIncludeStructPubSubType() { - setName("RelativePathIncludeStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(RelativePathIncludeStruct::getMaxCdrSerializedSize()); -#else - RelativePathIncludeStruct_max_cdr_typesize; -#endif + set_name("RelativePathIncludeStruct"); + uint32_t type_size = RelativePathIncludeStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = RelativePathIncludeStruct_max_key_cdr_typesize > 16 ? RelativePathIncludeStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = RelativePathIncludeStruct_max_key_cdr_typesize > 16 ? RelativePathIncludeStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } RelativePathIncludeStructPubSubType::~RelativePathIncludeStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool RelativePathIncludeStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const RelativePathIncludeStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool RelativePathIncludeStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool RelativePathIncludeStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool RelativePathIncludeStructPubSubType::deserialize( RelativePathIncludeStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool RelativePathIncludeStructPubSubType::deserialize( return true; } -std::function RelativePathIncludeStructPubSubType::getSerializedSizeProvider( +uint32_t RelativePathIncludeStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* RelativePathIncludeStructPubSubType::createData() +void* RelativePathIncludeStructPubSubType::create_data() { return reinterpret_cast(new RelativePathIncludeStruct()); } -void RelativePathIncludeStructPubSubType::deleteData( +void RelativePathIncludeStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool RelativePathIncludeStructPubSubType::getKey( +bool RelativePathIncludeStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + RelativePathIncludeStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool RelativePathIncludeStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool RelativePathIncludeStructPubSubType::getKey( const RelativePathIncludeStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), RelativePathIncludeStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || RelativePathIncludeStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/relative_path_includePubSubTypes.hpp b/test/dds-types-test/relative_path_includePubSubTypes.hpp index a3a64030f8a..95a3d1eeffd 100644 --- a/test/dds-types-test/relative_path_includePubSubTypes.hpp +++ b/test/dds-types-test/relative_path_includePubSubTypes.hpp @@ -33,10 +33,10 @@ #include "../IDL/helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated relative_path_include is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class RelativePathIncludeStructPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class RelativePathIncludeStructPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class RelativePathIncludeStructPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/sequencesPubSubTypes.cxx b/test/dds-types-test/sequencesPubSubTypes.cxx index fa8daeddeaf..de730b3450d 100644 --- a/test/dds-types-test/sequencesPubSubTypes.cxx +++ b/test/dds-types-test/sequencesPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; SequenceShortPubSubType::SequenceShortPubSubType() { - setName("SequenceShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceShort::getMaxCdrSerializedSize()); -#else - SequenceShort_max_cdr_typesize; -#endif + set_name("SequenceShort"); + uint32_t type_size = SequenceShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceShort_max_key_cdr_typesize > 16 ? SequenceShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceShort_max_key_cdr_typesize > 16 ? SequenceShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceShortPubSubType::~SequenceShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool SequenceShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool SequenceShortPubSubType::deserialize( SequenceShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool SequenceShortPubSubType::deserialize( return true; } -std::function SequenceShortPubSubType::getSerializedSizeProvider( +uint32_t SequenceShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceShortPubSubType::createData() + 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* SequenceShortPubSubType::create_data() { return reinterpret_cast(new SequenceShort()); } -void SequenceShortPubSubType::deleteData( +void SequenceShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceShortPubSubType::getKey( +bool SequenceShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool SequenceShortPubSubType::getKey( const SequenceShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void SequenceShortPubSubType::register_type_object_representation() SequenceUShortPubSubType::SequenceUShortPubSubType() { - setName("SequenceUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceUShort::getMaxCdrSerializedSize()); -#else - SequenceUShort_max_cdr_typesize; -#endif + set_name("SequenceUShort"); + uint32_t type_size = SequenceUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceUShort_max_key_cdr_typesize > 16 ? SequenceUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceUShort_max_key_cdr_typesize > 16 ? SequenceUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceUShortPubSubType::~SequenceUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool SequenceUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool SequenceUShortPubSubType::deserialize( SequenceUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool SequenceUShortPubSubType::deserialize( return true; } -std::function SequenceUShortPubSubType::getSerializedSizeProvider( +uint32_t SequenceUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceUShortPubSubType::createData() + 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* SequenceUShortPubSubType::create_data() { return reinterpret_cast(new SequenceUShort()); } -void SequenceUShortPubSubType::deleteData( +void SequenceUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceUShortPubSubType::getKey( +bool SequenceUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool SequenceUShortPubSubType::getKey( const SequenceUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void SequenceUShortPubSubType::register_type_object_representation() SequenceLongPubSubType::SequenceLongPubSubType() { - setName("SequenceLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceLong::getMaxCdrSerializedSize()); -#else - SequenceLong_max_cdr_typesize; -#endif + set_name("SequenceLong"); + uint32_t type_size = SequenceLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceLong_max_key_cdr_typesize > 16 ? SequenceLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceLong_max_key_cdr_typesize > 16 ? SequenceLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceLongPubSubType::~SequenceLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool SequenceLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool SequenceLongPubSubType::deserialize( SequenceLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool SequenceLongPubSubType::deserialize( return true; } -std::function SequenceLongPubSubType::getSerializedSizeProvider( +uint32_t SequenceLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceLongPubSubType::createData() + 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* SequenceLongPubSubType::create_data() { return reinterpret_cast(new SequenceLong()); } -void SequenceLongPubSubType::deleteData( +void SequenceLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceLongPubSubType::getKey( +bool SequenceLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool SequenceLongPubSubType::getKey( const SequenceLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void SequenceLongPubSubType::register_type_object_representation() SequenceULongPubSubType::SequenceULongPubSubType() { - setName("SequenceULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceULong::getMaxCdrSerializedSize()); -#else - SequenceULong_max_cdr_typesize; -#endif + set_name("SequenceULong"); + uint32_t type_size = SequenceULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceULong_max_key_cdr_typesize > 16 ? SequenceULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceULong_max_key_cdr_typesize > 16 ? SequenceULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceULongPubSubType::~SequenceULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool SequenceULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool SequenceULongPubSubType::deserialize( SequenceULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool SequenceULongPubSubType::deserialize( return true; } -std::function SequenceULongPubSubType::getSerializedSizeProvider( +uint32_t SequenceULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceULongPubSubType::createData() + 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* SequenceULongPubSubType::create_data() { return reinterpret_cast(new SequenceULong()); } -void SequenceULongPubSubType::deleteData( +void SequenceULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceULongPubSubType::getKey( +bool SequenceULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool SequenceULongPubSubType::getKey( const SequenceULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void SequenceULongPubSubType::register_type_object_representation() SequenceLongLongPubSubType::SequenceLongLongPubSubType() { - setName("SequenceLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceLongLong::getMaxCdrSerializedSize()); -#else - SequenceLongLong_max_cdr_typesize; -#endif + set_name("SequenceLongLong"); + uint32_t type_size = SequenceLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceLongLong_max_key_cdr_typesize > 16 ? SequenceLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceLongLong_max_key_cdr_typesize > 16 ? SequenceLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceLongLongPubSubType::~SequenceLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool SequenceLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool SequenceLongLongPubSubType::deserialize( SequenceLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool SequenceLongLongPubSubType::deserialize( return true; } -std::function SequenceLongLongPubSubType::getSerializedSizeProvider( +uint32_t SequenceLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceLongLongPubSubType::createData() + 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* SequenceLongLongPubSubType::create_data() { return reinterpret_cast(new SequenceLongLong()); } -void SequenceLongLongPubSubType::deleteData( +void SequenceLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceLongLongPubSubType::getKey( +bool SequenceLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool SequenceLongLongPubSubType::getKey( const SequenceLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void SequenceLongLongPubSubType::register_type_object_representation() SequenceULongLongPubSubType::SequenceULongLongPubSubType() { - setName("SequenceULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceULongLong::getMaxCdrSerializedSize()); -#else - SequenceULongLong_max_cdr_typesize; -#endif + set_name("SequenceULongLong"); + uint32_t type_size = SequenceULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceULongLong_max_key_cdr_typesize > 16 ? SequenceULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceULongLong_max_key_cdr_typesize > 16 ? SequenceULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceULongLongPubSubType::~SequenceULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool SequenceULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool SequenceULongLongPubSubType::deserialize( SequenceULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool SequenceULongLongPubSubType::deserialize( return true; } -std::function SequenceULongLongPubSubType::getSerializedSizeProvider( +uint32_t SequenceULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceULongLongPubSubType::createData() + 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* SequenceULongLongPubSubType::create_data() { return reinterpret_cast(new SequenceULongLong()); } -void SequenceULongLongPubSubType::deleteData( +void SequenceULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceULongLongPubSubType::getKey( +bool SequenceULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool SequenceULongLongPubSubType::getKey( const SequenceULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void SequenceULongLongPubSubType::register_type_object_representation() SequenceFloatPubSubType::SequenceFloatPubSubType() { - setName("SequenceFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceFloat::getMaxCdrSerializedSize()); -#else - SequenceFloat_max_cdr_typesize; -#endif + set_name("SequenceFloat"); + uint32_t type_size = SequenceFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceFloat_max_key_cdr_typesize > 16 ? SequenceFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceFloat_max_key_cdr_typesize > 16 ? SequenceFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceFloatPubSubType::~SequenceFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool SequenceFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool SequenceFloatPubSubType::deserialize( SequenceFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool SequenceFloatPubSubType::deserialize( return true; } -std::function SequenceFloatPubSubType::getSerializedSizeProvider( +uint32_t SequenceFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceFloatPubSubType::createData() + 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* SequenceFloatPubSubType::create_data() { return reinterpret_cast(new SequenceFloat()); } -void SequenceFloatPubSubType::deleteData( +void SequenceFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceFloatPubSubType::getKey( +bool SequenceFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool SequenceFloatPubSubType::getKey( const SequenceFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void SequenceFloatPubSubType::register_type_object_representation() SequenceDoublePubSubType::SequenceDoublePubSubType() { - setName("SequenceDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceDouble::getMaxCdrSerializedSize()); -#else - SequenceDouble_max_cdr_typesize; -#endif + set_name("SequenceDouble"); + uint32_t type_size = SequenceDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceDouble_max_key_cdr_typesize > 16 ? SequenceDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceDouble_max_key_cdr_typesize > 16 ? SequenceDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceDoublePubSubType::~SequenceDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool SequenceDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool SequenceDoublePubSubType::deserialize( SequenceDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool SequenceDoublePubSubType::deserialize( return true; } -std::function SequenceDoublePubSubType::getSerializedSizeProvider( +uint32_t SequenceDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceDoublePubSubType::createData() + 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* SequenceDoublePubSubType::create_data() { return reinterpret_cast(new SequenceDouble()); } -void SequenceDoublePubSubType::deleteData( +void SequenceDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceDoublePubSubType::getKey( +bool SequenceDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool SequenceDoublePubSubType::getKey( const SequenceDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void SequenceDoublePubSubType::register_type_object_representation() SequenceLongDoublePubSubType::SequenceLongDoublePubSubType() { - setName("SequenceLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceLongDouble::getMaxCdrSerializedSize()); -#else - SequenceLongDouble_max_cdr_typesize; -#endif + set_name("SequenceLongDouble"); + uint32_t type_size = SequenceLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceLongDouble_max_key_cdr_typesize > 16 ? SequenceLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceLongDouble_max_key_cdr_typesize > 16 ? SequenceLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceLongDoublePubSubType::~SequenceLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool SequenceLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool SequenceLongDoublePubSubType::deserialize( SequenceLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool SequenceLongDoublePubSubType::deserialize( return true; } -std::function SequenceLongDoublePubSubType::getSerializedSizeProvider( +uint32_t SequenceLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceLongDoublePubSubType::createData() + 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* SequenceLongDoublePubSubType::create_data() { return reinterpret_cast(new SequenceLongDouble()); } -void SequenceLongDoublePubSubType::deleteData( +void SequenceLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceLongDoublePubSubType::getKey( +bool SequenceLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool SequenceLongDoublePubSubType::getKey( const SequenceLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void SequenceLongDoublePubSubType::register_type_object_representation() SequenceBooleanPubSubType::SequenceBooleanPubSubType() { - setName("SequenceBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceBoolean::getMaxCdrSerializedSize()); -#else - SequenceBoolean_max_cdr_typesize; -#endif + set_name("SequenceBoolean"); + uint32_t type_size = SequenceBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceBoolean_max_key_cdr_typesize > 16 ? SequenceBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceBoolean_max_key_cdr_typesize > 16 ? SequenceBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceBooleanPubSubType::~SequenceBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool SequenceBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool SequenceBooleanPubSubType::deserialize( SequenceBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool SequenceBooleanPubSubType::deserialize( return true; } -std::function SequenceBooleanPubSubType::getSerializedSizeProvider( +uint32_t SequenceBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceBooleanPubSubType::createData() + 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* SequenceBooleanPubSubType::create_data() { return reinterpret_cast(new SequenceBoolean()); } -void SequenceBooleanPubSubType::deleteData( +void SequenceBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceBooleanPubSubType::getKey( +bool SequenceBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool SequenceBooleanPubSubType::getKey( const SequenceBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void SequenceBooleanPubSubType::register_type_object_representation() SequenceOctetPubSubType::SequenceOctetPubSubType() { - setName("SequenceOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceOctet::getMaxCdrSerializedSize()); -#else - SequenceOctet_max_cdr_typesize; -#endif + set_name("SequenceOctet"); + uint32_t type_size = SequenceOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceOctet_max_key_cdr_typesize > 16 ? SequenceOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceOctet_max_key_cdr_typesize > 16 ? SequenceOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceOctetPubSubType::~SequenceOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool SequenceOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool SequenceOctetPubSubType::deserialize( SequenceOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool SequenceOctetPubSubType::deserialize( return true; } -std::function SequenceOctetPubSubType::getSerializedSizeProvider( +uint32_t SequenceOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceOctetPubSubType::createData() + 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* SequenceOctetPubSubType::create_data() { return reinterpret_cast(new SequenceOctet()); } -void SequenceOctetPubSubType::deleteData( +void SequenceOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceOctetPubSubType::getKey( +bool SequenceOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool SequenceOctetPubSubType::getKey( const SequenceOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void SequenceOctetPubSubType::register_type_object_representation() SequenceCharPubSubType::SequenceCharPubSubType() { - setName("SequenceChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceChar::getMaxCdrSerializedSize()); -#else - SequenceChar_max_cdr_typesize; -#endif + set_name("SequenceChar"); + uint32_t type_size = SequenceChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceChar_max_key_cdr_typesize > 16 ? SequenceChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceChar_max_key_cdr_typesize > 16 ? SequenceChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceCharPubSubType::~SequenceCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool SequenceCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool SequenceCharPubSubType::deserialize( SequenceChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool SequenceCharPubSubType::deserialize( return true; } -std::function SequenceCharPubSubType::getSerializedSizeProvider( +uint32_t SequenceCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceCharPubSubType::createData() + 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* SequenceCharPubSubType::create_data() { return reinterpret_cast(new SequenceChar()); } -void SequenceCharPubSubType::deleteData( +void SequenceCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceCharPubSubType::getKey( +bool SequenceCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool SequenceCharPubSubType::getKey( const SequenceChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void SequenceCharPubSubType::register_type_object_representation() SequenceWCharPubSubType::SequenceWCharPubSubType() { - setName("SequenceWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceWChar::getMaxCdrSerializedSize()); -#else - SequenceWChar_max_cdr_typesize; -#endif + set_name("SequenceWChar"); + uint32_t type_size = SequenceWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceWChar_max_key_cdr_typesize > 16 ? SequenceWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceWChar_max_key_cdr_typesize > 16 ? SequenceWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceWCharPubSubType::~SequenceWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool SequenceWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool SequenceWCharPubSubType::deserialize( SequenceWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,88 +2277,90 @@ bool SequenceWCharPubSubType::deserialize( return true; } -std::function SequenceWCharPubSubType::getSerializedSizeProvider( +uint32_t SequenceWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceWCharPubSubType::createData() + 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* SequenceWCharPubSubType::create_data() { return reinterpret_cast(new SequenceWChar()); } -void SequenceWCharPubSubType::deleteData( +void SequenceWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceWCharPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, +bool SequenceWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const SequenceWChar* p_type = static_cast(data); + SequenceWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - SequenceWChar_max_key_cdr_typesize); + return false; +} + +bool SequenceWCharPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const SequenceWChar* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + SequenceWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void SequenceWCharPubSubType::register_type_object_representation() SequenceStringPubSubType::SequenceStringPubSubType() { - setName("SequenceString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceString::getMaxCdrSerializedSize()); -#else - SequenceString_max_cdr_typesize; -#endif + set_name("SequenceString"); + uint32_t type_size = SequenceString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceString_max_key_cdr_typesize > 16 ? SequenceString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceString_max_key_cdr_typesize > 16 ? SequenceString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceStringPubSubType::~SequenceStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool SequenceStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool SequenceStringPubSubType::deserialize( SequenceString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool SequenceStringPubSubType::deserialize( return true; } -std::function SequenceStringPubSubType::getSerializedSizeProvider( +uint32_t SequenceStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceStringPubSubType::createData() + 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* SequenceStringPubSubType::create_data() { return reinterpret_cast(new SequenceString()); } -void SequenceStringPubSubType::deleteData( +void SequenceStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceStringPubSubType::getKey( +bool SequenceStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool SequenceStringPubSubType::getKey( const SequenceString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void SequenceStringPubSubType::register_type_object_representation() SequenceWStringPubSubType::SequenceWStringPubSubType() { - setName("SequenceWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceWString::getMaxCdrSerializedSize()); -#else - SequenceWString_max_cdr_typesize; -#endif + set_name("SequenceWString"); + uint32_t type_size = SequenceWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceWString_max_key_cdr_typesize > 16 ? SequenceWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceWString_max_key_cdr_typesize > 16 ? SequenceWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceWStringPubSubType::~SequenceWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool SequenceWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool SequenceWStringPubSubType::deserialize( SequenceWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool SequenceWStringPubSubType::deserialize( return true; } -std::function SequenceWStringPubSubType::getSerializedSizeProvider( +uint32_t SequenceWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceWStringPubSubType::createData() + 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* SequenceWStringPubSubType::create_data() { return reinterpret_cast(new SequenceWString()); } -void SequenceWStringPubSubType::deleteData( +void SequenceWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceWStringPubSubType::getKey( +bool SequenceWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool SequenceWStringPubSubType::getKey( const SequenceWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void SequenceWStringPubSubType::register_type_object_representation() SequenceStringBoundedPubSubType::SequenceStringBoundedPubSubType() { - setName("SequenceStringBounded"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceStringBounded::getMaxCdrSerializedSize()); -#else - SequenceStringBounded_max_cdr_typesize; -#endif + set_name("SequenceStringBounded"); + uint32_t type_size = SequenceStringBounded_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceStringBounded_max_key_cdr_typesize > 16 ? SequenceStringBounded_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceStringBounded_max_key_cdr_typesize > 16 ? SequenceStringBounded_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceStringBoundedPubSubType::~SequenceStringBoundedPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceStringBoundedPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceStringBounded* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool SequenceStringBoundedPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceStringBoundedPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool SequenceStringBoundedPubSubType::deserialize( SequenceStringBounded* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool SequenceStringBoundedPubSubType::deserialize( return true; } -std::function SequenceStringBoundedPubSubType::getSerializedSizeProvider( +uint32_t SequenceStringBoundedPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceStringBoundedPubSubType::createData() + 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* SequenceStringBoundedPubSubType::create_data() { return reinterpret_cast(new SequenceStringBounded()); } -void SequenceStringBoundedPubSubType::deleteData( +void SequenceStringBoundedPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceStringBoundedPubSubType::getKey( +bool SequenceStringBoundedPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceStringBounded data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceStringBoundedPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool SequenceStringBoundedPubSubType::getKey( const SequenceStringBounded* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceStringBounded_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceStringBounded_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void SequenceStringBoundedPubSubType::register_type_object_representation() SequenceWStringBoundedPubSubType::SequenceWStringBoundedPubSubType() { - setName("SequenceWStringBounded"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceWStringBounded::getMaxCdrSerializedSize()); -#else - SequenceWStringBounded_max_cdr_typesize; -#endif + set_name("SequenceWStringBounded"); + uint32_t type_size = SequenceWStringBounded_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceWStringBounded_max_key_cdr_typesize > 16 ? SequenceWStringBounded_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceWStringBounded_max_key_cdr_typesize > 16 ? SequenceWStringBounded_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceWStringBoundedPubSubType::~SequenceWStringBoundedPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceWStringBoundedPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceWStringBounded* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool SequenceWStringBoundedPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceWStringBoundedPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool SequenceWStringBoundedPubSubType::deserialize( SequenceWStringBounded* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool SequenceWStringBoundedPubSubType::deserialize( return true; } -std::function SequenceWStringBoundedPubSubType::getSerializedSizeProvider( +uint32_t SequenceWStringBoundedPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceWStringBoundedPubSubType::createData() + 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* SequenceWStringBoundedPubSubType::create_data() { return reinterpret_cast(new SequenceWStringBounded()); } -void SequenceWStringBoundedPubSubType::deleteData( +void SequenceWStringBoundedPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceWStringBoundedPubSubType::getKey( +bool SequenceWStringBoundedPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceWStringBounded data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceWStringBoundedPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool SequenceWStringBoundedPubSubType::getKey( const SequenceWStringBounded* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceWStringBounded_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceWStringBounded_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void SequenceWStringBoundedPubSubType::register_type_object_representation() SequenceEnumPubSubType::SequenceEnumPubSubType() { - setName("SequenceEnum"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceEnum::getMaxCdrSerializedSize()); -#else - SequenceEnum_max_cdr_typesize; -#endif + set_name("SequenceEnum"); + uint32_t type_size = SequenceEnum_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceEnum_max_key_cdr_typesize > 16 ? SequenceEnum_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceEnum_max_key_cdr_typesize > 16 ? SequenceEnum_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceEnumPubSubType::~SequenceEnumPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceEnumPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool SequenceEnumPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceEnumPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool SequenceEnumPubSubType::deserialize( SequenceEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool SequenceEnumPubSubType::deserialize( return true; } -std::function SequenceEnumPubSubType::getSerializedSizeProvider( +uint32_t SequenceEnumPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceEnumPubSubType::createData() + 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* SequenceEnumPubSubType::create_data() { return reinterpret_cast(new SequenceEnum()); } -void SequenceEnumPubSubType::deleteData( +void SequenceEnumPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceEnumPubSubType::getKey( +bool SequenceEnumPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceEnum data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceEnumPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool SequenceEnumPubSubType::getKey( const SequenceEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceEnum_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceEnum_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void SequenceEnumPubSubType::register_type_object_representation() SequenceBitMaskPubSubType::SequenceBitMaskPubSubType() { - setName("SequenceBitMask"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceBitMask::getMaxCdrSerializedSize()); -#else - SequenceBitMask_max_cdr_typesize; -#endif + set_name("SequenceBitMask"); + uint32_t type_size = SequenceBitMask_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceBitMask_max_key_cdr_typesize > 16 ? SequenceBitMask_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceBitMask_max_key_cdr_typesize > 16 ? SequenceBitMask_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceBitMaskPubSubType::~SequenceBitMaskPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceBitMaskPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool SequenceBitMaskPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceBitMaskPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool SequenceBitMaskPubSubType::deserialize( SequenceBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool SequenceBitMaskPubSubType::deserialize( return true; } -std::function SequenceBitMaskPubSubType::getSerializedSizeProvider( +uint32_t SequenceBitMaskPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceBitMaskPubSubType::createData() + 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* SequenceBitMaskPubSubType::create_data() { return reinterpret_cast(new SequenceBitMask()); } -void SequenceBitMaskPubSubType::deleteData( +void SequenceBitMaskPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceBitMaskPubSubType::getKey( +bool SequenceBitMaskPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceBitMask data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceBitMaskPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool SequenceBitMaskPubSubType::getKey( const SequenceBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceBitMask_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceBitMask_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3700,49 +3453,42 @@ void SequenceBitMaskPubSubType::register_type_object_representation() SequenceAliasPubSubType::SequenceAliasPubSubType() { - setName("SequenceAlias"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceAlias::getMaxCdrSerializedSize()); -#else - SequenceAlias_max_cdr_typesize; -#endif + set_name("SequenceAlias"); + uint32_t type_size = SequenceAlias_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceAlias_max_key_cdr_typesize > 16 ? SequenceAlias_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceAlias_max_key_cdr_typesize > 16 ? SequenceAlias_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceAliasPubSubType::~SequenceAliasPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceAliasPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3757,16 +3503,12 @@ bool SequenceAliasPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceAliasPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3775,18 +3517,14 @@ bool SequenceAliasPubSubType::deserialize( SequenceAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3799,52 +3537,62 @@ bool SequenceAliasPubSubType::deserialize( return true; } -std::function SequenceAliasPubSubType::getSerializedSizeProvider( +uint32_t SequenceAliasPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceAliasPubSubType::createData() + 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* SequenceAliasPubSubType::create_data() { return reinterpret_cast(new SequenceAlias()); } -void SequenceAliasPubSubType::deleteData( +void SequenceAliasPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceAliasPubSubType::getKey( +bool SequenceAliasPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceAlias data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceAliasPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3852,35 +3600,27 @@ bool SequenceAliasPubSubType::getKey( const SequenceAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceAlias_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceAlias_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3893,49 +3633,42 @@ void SequenceAliasPubSubType::register_type_object_representation() SequenceShortArrayPubSubType::SequenceShortArrayPubSubType() { - setName("SequenceShortArray"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceShortArray::getMaxCdrSerializedSize()); -#else - SequenceShortArray_max_cdr_typesize; -#endif + set_name("SequenceShortArray"); + uint32_t type_size = SequenceShortArray_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceShortArray_max_key_cdr_typesize > 16 ? SequenceShortArray_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceShortArray_max_key_cdr_typesize > 16 ? SequenceShortArray_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceShortArrayPubSubType::~SequenceShortArrayPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceShortArrayPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3950,16 +3683,12 @@ bool SequenceShortArrayPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceShortArrayPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3968,18 +3697,14 @@ bool SequenceShortArrayPubSubType::deserialize( SequenceShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3992,52 +3717,62 @@ bool SequenceShortArrayPubSubType::deserialize( return true; } -std::function SequenceShortArrayPubSubType::getSerializedSizeProvider( +uint32_t SequenceShortArrayPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceShortArrayPubSubType::createData() + 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* SequenceShortArrayPubSubType::create_data() { return reinterpret_cast(new SequenceShortArray()); } -void SequenceShortArrayPubSubType::deleteData( +void SequenceShortArrayPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceShortArrayPubSubType::getKey( +bool SequenceShortArrayPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceShortArray data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceShortArrayPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4045,35 +3780,27 @@ bool SequenceShortArrayPubSubType::getKey( const SequenceShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceShortArray_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceShortArray_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4086,49 +3813,42 @@ void SequenceShortArrayPubSubType::register_type_object_representation() SequenceSequencePubSubType::SequenceSequencePubSubType() { - setName("SequenceSequence"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceSequence::getMaxCdrSerializedSize()); -#else - SequenceSequence_max_cdr_typesize; -#endif + set_name("SequenceSequence"); + uint32_t type_size = SequenceSequence_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceSequence_max_key_cdr_typesize > 16 ? SequenceSequence_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceSequence_max_key_cdr_typesize > 16 ? SequenceSequence_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceSequencePubSubType::~SequenceSequencePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceSequencePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4143,16 +3863,12 @@ bool SequenceSequencePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceSequencePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4161,18 +3877,14 @@ bool SequenceSequencePubSubType::deserialize( SequenceSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4185,52 +3897,62 @@ bool SequenceSequencePubSubType::deserialize( return true; } -std::function SequenceSequencePubSubType::getSerializedSizeProvider( +uint32_t SequenceSequencePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceSequencePubSubType::createData() + 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* SequenceSequencePubSubType::create_data() { return reinterpret_cast(new SequenceSequence()); } -void SequenceSequencePubSubType::deleteData( +void SequenceSequencePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceSequencePubSubType::getKey( +bool SequenceSequencePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceSequence data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceSequencePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4238,35 +3960,27 @@ bool SequenceSequencePubSubType::getKey( const SequenceSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceSequence_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceSequence_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4279,49 +3993,42 @@ void SequenceSequencePubSubType::register_type_object_representation() SequenceMapPubSubType::SequenceMapPubSubType() { - setName("SequenceMap"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceMap::getMaxCdrSerializedSize()); -#else - SequenceMap_max_cdr_typesize; -#endif + set_name("SequenceMap"); + uint32_t type_size = SequenceMap_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceMap_max_key_cdr_typesize > 16 ? SequenceMap_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceMap_max_key_cdr_typesize > 16 ? SequenceMap_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceMapPubSubType::~SequenceMapPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceMapPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4336,16 +4043,12 @@ bool SequenceMapPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceMapPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4354,18 +4057,14 @@ bool SequenceMapPubSubType::deserialize( SequenceMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4378,52 +4077,62 @@ bool SequenceMapPubSubType::deserialize( return true; } -std::function SequenceMapPubSubType::getSerializedSizeProvider( +uint32_t SequenceMapPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceMapPubSubType::createData() + 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* SequenceMapPubSubType::create_data() { return reinterpret_cast(new SequenceMap()); } -void SequenceMapPubSubType::deleteData( +void SequenceMapPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceMapPubSubType::getKey( +bool SequenceMapPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceMap data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceMapPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4431,35 +4140,27 @@ bool SequenceMapPubSubType::getKey( const SequenceMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceMap_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceMap_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4472,49 +4173,42 @@ void SequenceMapPubSubType::register_type_object_representation() SequenceUnionPubSubType::SequenceUnionPubSubType() { - setName("SequenceUnion"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceUnion::getMaxCdrSerializedSize()); -#else - SequenceUnion_max_cdr_typesize; -#endif + set_name("SequenceUnion"); + uint32_t type_size = SequenceUnion_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceUnion_max_key_cdr_typesize > 16 ? SequenceUnion_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceUnion_max_key_cdr_typesize > 16 ? SequenceUnion_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceUnionPubSubType::~SequenceUnionPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceUnionPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4529,16 +4223,12 @@ bool SequenceUnionPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceUnionPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4547,18 +4237,14 @@ bool SequenceUnionPubSubType::deserialize( SequenceUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4571,52 +4257,62 @@ bool SequenceUnionPubSubType::deserialize( return true; } -std::function SequenceUnionPubSubType::getSerializedSizeProvider( +uint32_t SequenceUnionPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceUnionPubSubType::createData() + 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* SequenceUnionPubSubType::create_data() { return reinterpret_cast(new SequenceUnion()); } -void SequenceUnionPubSubType::deleteData( +void SequenceUnionPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceUnionPubSubType::getKey( +bool SequenceUnionPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceUnion data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceUnionPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4624,35 +4320,27 @@ bool SequenceUnionPubSubType::getKey( const SequenceUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceUnion_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceUnion_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4665,49 +4353,42 @@ void SequenceUnionPubSubType::register_type_object_representation() SequenceStructurePubSubType::SequenceStructurePubSubType() { - setName("SequenceStructure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceStructure::getMaxCdrSerializedSize()); -#else - SequenceStructure_max_cdr_typesize; -#endif + set_name("SequenceStructure"); + uint32_t type_size = SequenceStructure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceStructure_max_key_cdr_typesize > 16 ? SequenceStructure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceStructure_max_key_cdr_typesize > 16 ? SequenceStructure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceStructurePubSubType::~SequenceStructurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceStructurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4722,16 +4403,12 @@ bool SequenceStructurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceStructurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4740,18 +4417,14 @@ bool SequenceStructurePubSubType::deserialize( SequenceStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4764,52 +4437,62 @@ bool SequenceStructurePubSubType::deserialize( return true; } -std::function SequenceStructurePubSubType::getSerializedSizeProvider( +uint32_t SequenceStructurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceStructurePubSubType::createData() + 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* SequenceStructurePubSubType::create_data() { return reinterpret_cast(new SequenceStructure()); } -void SequenceStructurePubSubType::deleteData( +void SequenceStructurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceStructurePubSubType::getKey( +bool SequenceStructurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceStructure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceStructurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4817,35 +4500,27 @@ bool SequenceStructurePubSubType::getKey( const SequenceStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceStructure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceStructure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4858,49 +4533,42 @@ void SequenceStructurePubSubType::register_type_object_representation() SequenceBitsetPubSubType::SequenceBitsetPubSubType() { - setName("SequenceBitset"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceBitset::getMaxCdrSerializedSize()); -#else - SequenceBitset_max_cdr_typesize; -#endif + set_name("SequenceBitset"); + uint32_t type_size = SequenceBitset_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceBitset_max_key_cdr_typesize > 16 ? SequenceBitset_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceBitset_max_key_cdr_typesize > 16 ? SequenceBitset_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceBitsetPubSubType::~SequenceBitsetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceBitsetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4915,16 +4583,12 @@ bool SequenceBitsetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceBitsetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4933,18 +4597,14 @@ bool SequenceBitsetPubSubType::deserialize( SequenceBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4957,52 +4617,62 @@ bool SequenceBitsetPubSubType::deserialize( return true; } -std::function SequenceBitsetPubSubType::getSerializedSizeProvider( +uint32_t SequenceBitsetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SequenceBitsetPubSubType::createData() + 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* SequenceBitsetPubSubType::create_data() { return reinterpret_cast(new SequenceBitset()); } -void SequenceBitsetPubSubType::deleteData( +void SequenceBitsetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceBitsetPubSubType::getKey( +bool SequenceBitsetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceBitset data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceBitsetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5010,35 +4680,27 @@ bool SequenceBitsetPubSubType::getKey( const SequenceBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceBitset_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceBitset_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5051,49 +4713,42 @@ void SequenceBitsetPubSubType::register_type_object_representation() BoundedSmallSequencesPubSubType::BoundedSmallSequencesPubSubType() { - setName("BoundedSmallSequences"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BoundedSmallSequences::getMaxCdrSerializedSize()); -#else - BoundedSmallSequences_max_cdr_typesize; -#endif + set_name("BoundedSmallSequences"); + uint32_t type_size = BoundedSmallSequences_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BoundedSmallSequences_max_key_cdr_typesize > 16 ? BoundedSmallSequences_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BoundedSmallSequences_max_key_cdr_typesize > 16 ? BoundedSmallSequences_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BoundedSmallSequencesPubSubType::~BoundedSmallSequencesPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BoundedSmallSequencesPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BoundedSmallSequences* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5108,16 +4763,12 @@ bool BoundedSmallSequencesPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BoundedSmallSequencesPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5126,18 +4777,14 @@ bool BoundedSmallSequencesPubSubType::deserialize( BoundedSmallSequences* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5150,52 +4797,62 @@ bool BoundedSmallSequencesPubSubType::deserialize( return true; } -std::function BoundedSmallSequencesPubSubType::getSerializedSizeProvider( +uint32_t BoundedSmallSequencesPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* BoundedSmallSequencesPubSubType::createData() + 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* BoundedSmallSequencesPubSubType::create_data() { return reinterpret_cast(new BoundedSmallSequences()); } -void BoundedSmallSequencesPubSubType::deleteData( +void BoundedSmallSequencesPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BoundedSmallSequencesPubSubType::getKey( +bool BoundedSmallSequencesPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BoundedSmallSequences data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BoundedSmallSequencesPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5203,35 +4860,27 @@ bool BoundedSmallSequencesPubSubType::getKey( const BoundedSmallSequences* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BoundedSmallSequences_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BoundedSmallSequences_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5244,49 +4893,42 @@ void BoundedSmallSequencesPubSubType::register_type_object_representation() BoundedBigSequencesPubSubType::BoundedBigSequencesPubSubType() { - setName("BoundedBigSequences"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BoundedBigSequences::getMaxCdrSerializedSize()); -#else - BoundedBigSequences_max_cdr_typesize; -#endif + set_name("BoundedBigSequences"); + uint32_t type_size = BoundedBigSequences_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BoundedBigSequences_max_key_cdr_typesize > 16 ? BoundedBigSequences_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BoundedBigSequences_max_key_cdr_typesize > 16 ? BoundedBigSequences_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BoundedBigSequencesPubSubType::~BoundedBigSequencesPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BoundedBigSequencesPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BoundedBigSequences* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5301,16 +4943,12 @@ bool BoundedBigSequencesPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BoundedBigSequencesPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5319,18 +4957,14 @@ bool BoundedBigSequencesPubSubType::deserialize( BoundedBigSequences* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5343,52 +4977,62 @@ bool BoundedBigSequencesPubSubType::deserialize( return true; } -std::function BoundedBigSequencesPubSubType::getSerializedSizeProvider( +uint32_t BoundedBigSequencesPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* BoundedBigSequencesPubSubType::createData() + 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* BoundedBigSequencesPubSubType::create_data() { return reinterpret_cast(new BoundedBigSequences()); } -void BoundedBigSequencesPubSubType::deleteData( +void BoundedBigSequencesPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BoundedBigSequencesPubSubType::getKey( +bool BoundedBigSequencesPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BoundedBigSequences data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BoundedBigSequencesPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5396,35 +5040,27 @@ bool BoundedBigSequencesPubSubType::getKey( const BoundedBigSequences* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BoundedBigSequences_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BoundedBigSequences_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/sequencesPubSubTypes.hpp b/test/dds-types-test/sequencesPubSubTypes.hpp index 1026cb42b25..983f16fd33a 100644 --- a/test/dds-types-test/sequencesPubSubTypes.hpp +++ b/test/dds-types-test/sequencesPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated sequences is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class SequenceShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class SequenceShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class SequenceShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class SequenceUShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class SequenceUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class SequenceUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -237,38 +217,30 @@ class SequenceLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -283,10 +255,6 @@ class SequenceLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,8 +275,10 @@ class SequenceLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -328,38 +298,30 @@ class SequenceULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -374,10 +336,6 @@ class SequenceULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -398,8 +356,10 @@ class SequenceULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -419,38 +379,30 @@ class SequenceLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -465,10 +417,6 @@ class SequenceLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -489,8 +437,10 @@ class SequenceLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -510,38 +460,30 @@ class SequenceULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -556,10 +498,6 @@ class SequenceULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -580,8 +518,10 @@ class SequenceULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -601,38 +541,30 @@ class SequenceFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -647,10 +579,6 @@ class SequenceFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -671,8 +599,10 @@ class SequenceFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -692,38 +622,30 @@ class SequenceDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -738,10 +660,6 @@ class SequenceDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -762,8 +680,10 @@ class SequenceDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -783,38 +703,30 @@ class SequenceLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -829,10 +741,6 @@ class SequenceLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -853,8 +761,10 @@ class SequenceLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -874,38 +784,30 @@ class SequenceBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -920,10 +822,6 @@ class SequenceBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -944,8 +842,10 @@ class SequenceBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -965,38 +865,30 @@ class SequenceOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1011,10 +903,6 @@ class SequenceOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1035,8 +923,10 @@ class SequenceOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1056,38 +946,30 @@ class SequenceCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1102,10 +984,6 @@ class SequenceCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1126,8 +1004,10 @@ class SequenceCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1147,38 +1027,30 @@ class SequenceWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1193,10 +1065,6 @@ class SequenceWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1217,8 +1085,10 @@ class SequenceWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1238,38 +1108,30 @@ class SequenceStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1284,10 +1146,6 @@ class SequenceStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1308,8 +1166,10 @@ class SequenceStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1329,38 +1189,30 @@ class SequenceWStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1375,10 +1227,6 @@ class SequenceWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1399,8 +1247,10 @@ class SequenceWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1420,38 +1270,30 @@ class SequenceStringBoundedPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1466,10 +1308,6 @@ class SequenceStringBoundedPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1490,8 +1328,10 @@ class SequenceStringBoundedPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1511,38 +1351,30 @@ class SequenceWStringBoundedPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1557,10 +1389,6 @@ class SequenceWStringBoundedPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1581,8 +1409,10 @@ class SequenceWStringBoundedPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1602,38 +1432,30 @@ class SequenceEnumPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1648,10 +1470,6 @@ class SequenceEnumPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1672,8 +1490,10 @@ class SequenceEnumPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1693,38 +1513,30 @@ class SequenceBitMaskPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1739,10 +1551,6 @@ class SequenceBitMaskPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1763,8 +1571,10 @@ class SequenceBitMaskPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1784,38 +1594,30 @@ class SequenceAliasPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1830,10 +1632,6 @@ class SequenceAliasPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1854,8 +1652,10 @@ class SequenceAliasPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1875,38 +1675,30 @@ class SequenceShortArrayPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1921,10 +1713,6 @@ class SequenceShortArrayPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1945,8 +1733,10 @@ class SequenceShortArrayPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1966,38 +1756,30 @@ class SequenceSequencePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2012,10 +1794,6 @@ class SequenceSequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2036,8 +1814,10 @@ class SequenceSequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2057,38 +1837,30 @@ class SequenceMapPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2103,10 +1875,6 @@ class SequenceMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2127,8 +1895,10 @@ class SequenceMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2148,38 +1918,30 @@ class SequenceUnionPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2194,10 +1956,6 @@ class SequenceUnionPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2218,8 +1976,10 @@ class SequenceUnionPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2239,38 +1999,30 @@ class SequenceStructurePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2285,10 +2037,6 @@ class SequenceStructurePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2309,8 +2057,10 @@ class SequenceStructurePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2330,38 +2080,30 @@ class SequenceBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2376,10 +2118,6 @@ class SequenceBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2400,8 +2138,10 @@ class SequenceBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2421,38 +2161,30 @@ class BoundedSmallSequencesPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2467,10 +2199,6 @@ class BoundedSmallSequencesPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2491,8 +2219,10 @@ class BoundedSmallSequencesPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2512,38 +2242,30 @@ class BoundedBigSequencesPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2558,10 +2280,6 @@ class BoundedBigSequencesPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2582,8 +2300,10 @@ class BoundedBigSequencesPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/stringsPubSubTypes.cxx b/test/dds-types-test/stringsPubSubTypes.cxx index 5413c56d906..08203e8ddb7 100644 --- a/test/dds-types-test/stringsPubSubTypes.cxx +++ b/test/dds-types-test/stringsPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; StringStructPubSubType::StringStructPubSubType() { - setName("StringStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StringStruct::getMaxCdrSerializedSize()); -#else - StringStruct_max_cdr_typesize; -#endif + set_name("StringStruct"); + uint32_t type_size = StringStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StringStruct_max_key_cdr_typesize > 16 ? StringStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StringStruct_max_key_cdr_typesize > 16 ? StringStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StringStructPubSubType::~StringStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StringStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool StringStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StringStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool StringStructPubSubType::deserialize( StringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool StringStructPubSubType::deserialize( return true; } -std::function StringStructPubSubType::getSerializedSizeProvider( +uint32_t StringStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* StringStructPubSubType::createData() +void* StringStructPubSubType::create_data() { return reinterpret_cast(new StringStruct()); } -void StringStructPubSubType::deleteData( +void StringStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StringStructPubSubType::getKey( +bool StringStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StringStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StringStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool StringStructPubSubType::getKey( const StringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StringStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StringStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void StringStructPubSubType::register_type_object_representation() WStringStructPubSubType::WStringStructPubSubType() { - setName("WStringStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(WStringStruct::getMaxCdrSerializedSize()); -#else - WStringStruct_max_cdr_typesize; -#endif + set_name("WStringStruct"); + uint32_t type_size = WStringStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = WStringStruct_max_key_cdr_typesize > 16 ? WStringStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = WStringStruct_max_key_cdr_typesize > 16 ? WStringStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } WStringStructPubSubType::~WStringStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool WStringStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const WStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool WStringStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool WStringStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool WStringStructPubSubType::deserialize( WStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool WStringStructPubSubType::deserialize( return true; } -std::function WStringStructPubSubType::getSerializedSizeProvider( +uint32_t WStringStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* WStringStructPubSubType::createData() +void* WStringStructPubSubType::create_data() { return reinterpret_cast(new WStringStruct()); } -void WStringStructPubSubType::deleteData( +void WStringStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool WStringStructPubSubType::getKey( +bool WStringStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + WStringStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool WStringStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool WStringStructPubSubType::getKey( const WStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), WStringStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || WStringStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void WStringStructPubSubType::register_type_object_representation() SmallStringStructPubSubType::SmallStringStructPubSubType() { - setName("SmallStringStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SmallStringStruct::getMaxCdrSerializedSize()); -#else - SmallStringStruct_max_cdr_typesize; -#endif + set_name("SmallStringStruct"); + uint32_t type_size = SmallStringStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SmallStringStruct_max_key_cdr_typesize > 16 ? SmallStringStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SmallStringStruct_max_key_cdr_typesize > 16 ? SmallStringStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SmallStringStructPubSubType::~SmallStringStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SmallStringStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SmallStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool SmallStringStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SmallStringStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool SmallStringStructPubSubType::deserialize( SmallStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool SmallStringStructPubSubType::deserialize( return true; } -std::function SmallStringStructPubSubType::getSerializedSizeProvider( +uint32_t SmallStringStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* SmallStringStructPubSubType::createData() +void* SmallStringStructPubSubType::create_data() { return reinterpret_cast(new SmallStringStruct()); } -void SmallStringStructPubSubType::deleteData( +void SmallStringStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SmallStringStructPubSubType::getKey( +bool SmallStringStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SmallStringStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SmallStringStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool SmallStringStructPubSubType::getKey( const SmallStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SmallStringStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SmallStringStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void SmallStringStructPubSubType::register_type_object_representation() SmallWStringStructPubSubType::SmallWStringStructPubSubType() { - setName("SmallWStringStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SmallWStringStruct::getMaxCdrSerializedSize()); -#else - SmallWStringStruct_max_cdr_typesize; -#endif + set_name("SmallWStringStruct"); + uint32_t type_size = SmallWStringStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SmallWStringStruct_max_key_cdr_typesize > 16 ? SmallWStringStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SmallWStringStruct_max_key_cdr_typesize > 16 ? SmallWStringStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SmallWStringStructPubSubType::~SmallWStringStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SmallWStringStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SmallWStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool SmallWStringStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SmallWStringStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool SmallWStringStructPubSubType::deserialize( SmallWStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool SmallWStringStructPubSubType::deserialize( return true; } -std::function SmallWStringStructPubSubType::getSerializedSizeProvider( +uint32_t SmallWStringStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* SmallWStringStructPubSubType::createData() +void* SmallWStringStructPubSubType::create_data() { return reinterpret_cast(new SmallWStringStruct()); } -void SmallWStringStructPubSubType::deleteData( +void SmallWStringStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SmallWStringStructPubSubType::getKey( +bool SmallWStringStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SmallWStringStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SmallWStringStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool SmallWStringStructPubSubType::getKey( const SmallWStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SmallWStringStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SmallWStringStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void SmallWStringStructPubSubType::register_type_object_representation() LargeStringStructPubSubType::LargeStringStructPubSubType() { - setName("LargeStringStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(LargeStringStruct::getMaxCdrSerializedSize()); -#else - LargeStringStruct_max_cdr_typesize; -#endif + set_name("LargeStringStruct"); + uint32_t type_size = LargeStringStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = LargeStringStruct_max_key_cdr_typesize > 16 ? LargeStringStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = LargeStringStruct_max_key_cdr_typesize > 16 ? LargeStringStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } LargeStringStructPubSubType::~LargeStringStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool LargeStringStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const LargeStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool LargeStringStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool LargeStringStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool LargeStringStructPubSubType::deserialize( LargeStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool LargeStringStructPubSubType::deserialize( return true; } -std::function LargeStringStructPubSubType::getSerializedSizeProvider( +uint32_t LargeStringStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* LargeStringStructPubSubType::createData() +void* LargeStringStructPubSubType::create_data() { return reinterpret_cast(new LargeStringStruct()); } -void LargeStringStructPubSubType::deleteData( +void LargeStringStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool LargeStringStructPubSubType::getKey( +bool LargeStringStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + LargeStringStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool LargeStringStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool LargeStringStructPubSubType::getKey( const LargeStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), LargeStringStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || LargeStringStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void LargeStringStructPubSubType::register_type_object_representation() LargeWStringStructPubSubType::LargeWStringStructPubSubType() { - setName("LargeWStringStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(LargeWStringStruct::getMaxCdrSerializedSize()); -#else - LargeWStringStruct_max_cdr_typesize; -#endif + set_name("LargeWStringStruct"); + uint32_t type_size = LargeWStringStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = LargeWStringStruct_max_key_cdr_typesize > 16 ? LargeWStringStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = LargeWStringStruct_max_key_cdr_typesize > 16 ? LargeWStringStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } LargeWStringStructPubSubType::~LargeWStringStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool LargeWStringStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const LargeWStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool LargeWStringStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool LargeWStringStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool LargeWStringStructPubSubType::deserialize( LargeWStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool LargeWStringStructPubSubType::deserialize( return true; } -std::function LargeWStringStructPubSubType::getSerializedSizeProvider( +uint32_t LargeWStringStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* LargeWStringStructPubSubType::createData() +void* LargeWStringStructPubSubType::create_data() { return reinterpret_cast(new LargeWStringStruct()); } -void LargeWStringStructPubSubType::deleteData( +void LargeWStringStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool LargeWStringStructPubSubType::getKey( +bool LargeWStringStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + LargeWStringStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool LargeWStringStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool LargeWStringStructPubSubType::getKey( const LargeWStringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), LargeWStringStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || LargeWStringStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/stringsPubSubTypes.hpp b/test/dds-types-test/stringsPubSubTypes.hpp index d05e089cec4..76bda9bdcca 100644 --- a/test/dds-types-test/stringsPubSubTypes.hpp +++ b/test/dds-types-test/stringsPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "strings.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated strings is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class StringStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class StringStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class StringStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -145,38 +135,30 @@ class WStringStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -191,10 +173,6 @@ class WStringStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,8 +193,10 @@ class WStringStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -236,38 +216,30 @@ class SmallStringStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -282,10 +254,6 @@ class SmallStringStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -306,8 +274,10 @@ class SmallStringStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -327,38 +297,30 @@ class SmallWStringStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -373,10 +335,6 @@ class SmallWStringStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -397,8 +355,10 @@ class SmallWStringStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -418,38 +378,30 @@ class LargeStringStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -464,10 +416,6 @@ class LargeStringStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -488,8 +436,10 @@ class LargeStringStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -509,38 +459,30 @@ class LargeWStringStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -555,10 +497,6 @@ class LargeWStringStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -579,8 +517,10 @@ class LargeWStringStructPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/structuresPubSubTypes.cxx b/test/dds-types-test/structuresPubSubTypes.cxx index 73fb45440ad..f3badc858d4 100644 --- a/test/dds-types-test/structuresPubSubTypes.cxx +++ b/test/dds-types-test/structuresPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; StructShortPubSubType::StructShortPubSubType() { - setName("StructShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructShort::getMaxCdrSerializedSize()); -#else - StructShort_max_cdr_typesize; -#endif + set_name("StructShort"); + uint32_t type_size = StructShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructShort_max_key_cdr_typesize > 16 ? StructShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructShort_max_key_cdr_typesize > 16 ? StructShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructShortPubSubType::~StructShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool StructShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool StructShortPubSubType::deserialize( StructShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool StructShortPubSubType::deserialize( return true; } -std::function StructShortPubSubType::getSerializedSizeProvider( +uint32_t StructShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructShortPubSubType::createData() + 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* StructShortPubSubType::create_data() { return reinterpret_cast(new StructShort()); } -void StructShortPubSubType::deleteData( +void StructShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructShortPubSubType::getKey( +bool StructShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool StructShortPubSubType::getKey( const StructShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void StructShortPubSubType::register_type_object_representation() StructUnsignedShortPubSubType::StructUnsignedShortPubSubType() { - setName("StructUnsignedShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructUnsignedShort::getMaxCdrSerializedSize()); -#else - StructUnsignedShort_max_cdr_typesize; -#endif + set_name("StructUnsignedShort"); + uint32_t type_size = StructUnsignedShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructUnsignedShort_max_key_cdr_typesize > 16 ? StructUnsignedShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructUnsignedShort_max_key_cdr_typesize > 16 ? StructUnsignedShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructUnsignedShortPubSubType::~StructUnsignedShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructUnsignedShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructUnsignedShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool StructUnsignedShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructUnsignedShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool StructUnsignedShortPubSubType::deserialize( StructUnsignedShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool StructUnsignedShortPubSubType::deserialize( return true; } -std::function StructUnsignedShortPubSubType::getSerializedSizeProvider( +uint32_t StructUnsignedShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructUnsignedShortPubSubType::createData() + 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* StructUnsignedShortPubSubType::create_data() { return reinterpret_cast(new StructUnsignedShort()); } -void StructUnsignedShortPubSubType::deleteData( +void StructUnsignedShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructUnsignedShortPubSubType::getKey( +bool StructUnsignedShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructUnsignedShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructUnsignedShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool StructUnsignedShortPubSubType::getKey( const StructUnsignedShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructUnsignedShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructUnsignedShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void StructUnsignedShortPubSubType::register_type_object_representation() StructLongPubSubType::StructLongPubSubType() { - setName("StructLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructLong::getMaxCdrSerializedSize()); -#else - StructLong_max_cdr_typesize; -#endif + set_name("StructLong"); + uint32_t type_size = StructLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructLong_max_key_cdr_typesize > 16 ? StructLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructLong_max_key_cdr_typesize > 16 ? StructLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructLongPubSubType::~StructLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool StructLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool StructLongPubSubType::deserialize( StructLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool StructLongPubSubType::deserialize( return true; } -std::function StructLongPubSubType::getSerializedSizeProvider( +uint32_t StructLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructLongPubSubType::createData() + 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* StructLongPubSubType::create_data() { return reinterpret_cast(new StructLong()); } -void StructLongPubSubType::deleteData( +void StructLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructLongPubSubType::getKey( +bool StructLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool StructLongPubSubType::getKey( const StructLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void StructLongPubSubType::register_type_object_representation() StructUnsignedLongPubSubType::StructUnsignedLongPubSubType() { - setName("StructUnsignedLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructUnsignedLong::getMaxCdrSerializedSize()); -#else - StructUnsignedLong_max_cdr_typesize; -#endif + set_name("StructUnsignedLong"); + uint32_t type_size = StructUnsignedLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructUnsignedLong_max_key_cdr_typesize > 16 ? StructUnsignedLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructUnsignedLong_max_key_cdr_typesize > 16 ? StructUnsignedLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructUnsignedLongPubSubType::~StructUnsignedLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructUnsignedLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructUnsignedLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool StructUnsignedLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructUnsignedLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool StructUnsignedLongPubSubType::deserialize( StructUnsignedLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool StructUnsignedLongPubSubType::deserialize( return true; } -std::function StructUnsignedLongPubSubType::getSerializedSizeProvider( +uint32_t StructUnsignedLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructUnsignedLongPubSubType::createData() + 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* StructUnsignedLongPubSubType::create_data() { return reinterpret_cast(new StructUnsignedLong()); } -void StructUnsignedLongPubSubType::deleteData( +void StructUnsignedLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructUnsignedLongPubSubType::getKey( +bool StructUnsignedLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructUnsignedLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructUnsignedLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool StructUnsignedLongPubSubType::getKey( const StructUnsignedLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructUnsignedLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructUnsignedLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void StructUnsignedLongPubSubType::register_type_object_representation() StructLongLongPubSubType::StructLongLongPubSubType() { - setName("StructLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructLongLong::getMaxCdrSerializedSize()); -#else - StructLongLong_max_cdr_typesize; -#endif + set_name("StructLongLong"); + uint32_t type_size = StructLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructLongLong_max_key_cdr_typesize > 16 ? StructLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructLongLong_max_key_cdr_typesize > 16 ? StructLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructLongLongPubSubType::~StructLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool StructLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool StructLongLongPubSubType::deserialize( StructLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool StructLongLongPubSubType::deserialize( return true; } -std::function StructLongLongPubSubType::getSerializedSizeProvider( +uint32_t StructLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructLongLongPubSubType::createData() + 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* StructLongLongPubSubType::create_data() { return reinterpret_cast(new StructLongLong()); } -void StructLongLongPubSubType::deleteData( +void StructLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructLongLongPubSubType::getKey( +bool StructLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool StructLongLongPubSubType::getKey( const StructLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void StructLongLongPubSubType::register_type_object_representation() StructUnsignedLongLongPubSubType::StructUnsignedLongLongPubSubType() { - setName("StructUnsignedLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructUnsignedLongLong::getMaxCdrSerializedSize()); -#else - StructUnsignedLongLong_max_cdr_typesize; -#endif + set_name("StructUnsignedLongLong"); + uint32_t type_size = StructUnsignedLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructUnsignedLongLong_max_key_cdr_typesize > 16 ? StructUnsignedLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructUnsignedLongLong_max_key_cdr_typesize > 16 ? StructUnsignedLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructUnsignedLongLongPubSubType::~StructUnsignedLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructUnsignedLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructUnsignedLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool StructUnsignedLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructUnsignedLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool StructUnsignedLongLongPubSubType::deserialize( StructUnsignedLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool StructUnsignedLongLongPubSubType::deserialize( return true; } -std::function StructUnsignedLongLongPubSubType::getSerializedSizeProvider( +uint32_t StructUnsignedLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructUnsignedLongLongPubSubType::createData() + 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* StructUnsignedLongLongPubSubType::create_data() { return reinterpret_cast(new StructUnsignedLongLong()); } -void StructUnsignedLongLongPubSubType::deleteData( +void StructUnsignedLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructUnsignedLongLongPubSubType::getKey( +bool StructUnsignedLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructUnsignedLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructUnsignedLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool StructUnsignedLongLongPubSubType::getKey( const StructUnsignedLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructUnsignedLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructUnsignedLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void StructUnsignedLongLongPubSubType::register_type_object_representation() StructFloatPubSubType::StructFloatPubSubType() { - setName("StructFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructFloat::getMaxCdrSerializedSize()); -#else - StructFloat_max_cdr_typesize; -#endif + set_name("StructFloat"); + uint32_t type_size = StructFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructFloat_max_key_cdr_typesize > 16 ? StructFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructFloat_max_key_cdr_typesize > 16 ? StructFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructFloatPubSubType::~StructFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool StructFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool StructFloatPubSubType::deserialize( StructFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool StructFloatPubSubType::deserialize( return true; } -std::function StructFloatPubSubType::getSerializedSizeProvider( +uint32_t StructFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructFloatPubSubType::createData() + 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* StructFloatPubSubType::create_data() { return reinterpret_cast(new StructFloat()); } -void StructFloatPubSubType::deleteData( +void StructFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructFloatPubSubType::getKey( +bool StructFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool StructFloatPubSubType::getKey( const StructFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void StructFloatPubSubType::register_type_object_representation() StructDoublePubSubType::StructDoublePubSubType() { - setName("StructDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructDouble::getMaxCdrSerializedSize()); -#else - StructDouble_max_cdr_typesize; -#endif + set_name("StructDouble"); + uint32_t type_size = StructDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructDouble_max_key_cdr_typesize > 16 ? StructDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructDouble_max_key_cdr_typesize > 16 ? StructDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructDoublePubSubType::~StructDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool StructDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool StructDoublePubSubType::deserialize( StructDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool StructDoublePubSubType::deserialize( return true; } -std::function StructDoublePubSubType::getSerializedSizeProvider( +uint32_t StructDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructDoublePubSubType::createData() + 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* StructDoublePubSubType::create_data() { return reinterpret_cast(new StructDouble()); } -void StructDoublePubSubType::deleteData( +void StructDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructDoublePubSubType::getKey( +bool StructDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool StructDoublePubSubType::getKey( const StructDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void StructDoublePubSubType::register_type_object_representation() StructLongDoublePubSubType::StructLongDoublePubSubType() { - setName("StructLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructLongDouble::getMaxCdrSerializedSize()); -#else - StructLongDouble_max_cdr_typesize; -#endif + set_name("StructLongDouble"); + uint32_t type_size = StructLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructLongDouble_max_key_cdr_typesize > 16 ? StructLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructLongDouble_max_key_cdr_typesize > 16 ? StructLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructLongDoublePubSubType::~StructLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool StructLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool StructLongDoublePubSubType::deserialize( StructLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool StructLongDoublePubSubType::deserialize( return true; } -std::function StructLongDoublePubSubType::getSerializedSizeProvider( +uint32_t StructLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructLongDoublePubSubType::createData() + 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* StructLongDoublePubSubType::create_data() { return reinterpret_cast(new StructLongDouble()); } -void StructLongDoublePubSubType::deleteData( +void StructLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructLongDoublePubSubType::getKey( +bool StructLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool StructLongDoublePubSubType::getKey( const StructLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void StructLongDoublePubSubType::register_type_object_representation() StructBooleanPubSubType::StructBooleanPubSubType() { - setName("StructBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructBoolean::getMaxCdrSerializedSize()); -#else - StructBoolean_max_cdr_typesize; -#endif + set_name("StructBoolean"); + uint32_t type_size = StructBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructBoolean_max_key_cdr_typesize > 16 ? StructBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructBoolean_max_key_cdr_typesize > 16 ? StructBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructBooleanPubSubType::~StructBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool StructBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool StructBooleanPubSubType::deserialize( StructBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool StructBooleanPubSubType::deserialize( return true; } -std::function StructBooleanPubSubType::getSerializedSizeProvider( +uint32_t StructBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructBooleanPubSubType::createData() + 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* StructBooleanPubSubType::create_data() { return reinterpret_cast(new StructBoolean()); } -void StructBooleanPubSubType::deleteData( +void StructBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructBooleanPubSubType::getKey( +bool StructBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool StructBooleanPubSubType::getKey( const StructBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void StructBooleanPubSubType::register_type_object_representation() StructOctetPubSubType::StructOctetPubSubType() { - setName("StructOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructOctet::getMaxCdrSerializedSize()); -#else - StructOctet_max_cdr_typesize; -#endif + set_name("StructOctet"); + uint32_t type_size = StructOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructOctet_max_key_cdr_typesize > 16 ? StructOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructOctet_max_key_cdr_typesize > 16 ? StructOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructOctetPubSubType::~StructOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool StructOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool StructOctetPubSubType::deserialize( StructOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool StructOctetPubSubType::deserialize( return true; } -std::function StructOctetPubSubType::getSerializedSizeProvider( +uint32_t StructOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructOctetPubSubType::createData() + 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* StructOctetPubSubType::create_data() { return reinterpret_cast(new StructOctet()); } -void StructOctetPubSubType::deleteData( +void StructOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructOctetPubSubType::getKey( +bool StructOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool StructOctetPubSubType::getKey( const StructOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void StructOctetPubSubType::register_type_object_representation() StructChar8PubSubType::StructChar8PubSubType() { - setName("StructChar8"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructChar8::getMaxCdrSerializedSize()); -#else - StructChar8_max_cdr_typesize; -#endif + set_name("StructChar8"); + uint32_t type_size = StructChar8_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructChar8_max_key_cdr_typesize > 16 ? StructChar8_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructChar8_max_key_cdr_typesize > 16 ? StructChar8_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructChar8PubSubType::~StructChar8PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructChar8PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructChar8* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool StructChar8PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructChar8PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool StructChar8PubSubType::deserialize( StructChar8* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool StructChar8PubSubType::deserialize( return true; } -std::function StructChar8PubSubType::getSerializedSizeProvider( +uint32_t StructChar8PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructChar8PubSubType::createData() + 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* StructChar8PubSubType::create_data() { return reinterpret_cast(new StructChar8()); } -void StructChar8PubSubType::deleteData( +void StructChar8PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructChar8PubSubType::getKey( +bool StructChar8PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructChar8 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructChar8PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool StructChar8PubSubType::getKey( const StructChar8* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructChar8_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructChar8_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void StructChar8PubSubType::register_type_object_representation() StructChar16PubSubType::StructChar16PubSubType() { - setName("StructChar16"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructChar16::getMaxCdrSerializedSize()); -#else - StructChar16_max_cdr_typesize; -#endif + set_name("StructChar16"); + uint32_t type_size = StructChar16_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructChar16_max_key_cdr_typesize > 16 ? StructChar16_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructChar16_max_key_cdr_typesize > 16 ? StructChar16_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructChar16PubSubType::~StructChar16PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructChar16PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructChar16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool StructChar16PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructChar16PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool StructChar16PubSubType::deserialize( StructChar16* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,88 +2277,90 @@ bool StructChar16PubSubType::deserialize( return true; } -std::function StructChar16PubSubType::getSerializedSizeProvider( +uint32_t StructChar16PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructChar16PubSubType::createData() + 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* StructChar16PubSubType::create_data() { return reinterpret_cast(new StructChar16()); } -void StructChar16PubSubType::deleteData( +void StructChar16PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructChar16PubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, +bool StructChar16PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const StructChar16* p_type = static_cast(data); + StructChar16 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - StructChar16_max_key_cdr_typesize); + return false; +} + +bool StructChar16PubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const StructChar16* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + StructChar16_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructChar16_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void StructChar16PubSubType::register_type_object_representation() StructStringPubSubType::StructStringPubSubType() { - setName("StructString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructString::getMaxCdrSerializedSize()); -#else - StructString_max_cdr_typesize; -#endif + set_name("StructString"); + uint32_t type_size = StructString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructString_max_key_cdr_typesize > 16 ? StructString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructString_max_key_cdr_typesize > 16 ? StructString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructStringPubSubType::~StructStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool StructStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool StructStringPubSubType::deserialize( StructString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool StructStringPubSubType::deserialize( return true; } -std::function StructStringPubSubType::getSerializedSizeProvider( +uint32_t StructStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructStringPubSubType::createData() + 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* StructStringPubSubType::create_data() { return reinterpret_cast(new StructString()); } -void StructStringPubSubType::deleteData( +void StructStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructStringPubSubType::getKey( +bool StructStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool StructStringPubSubType::getKey( const StructString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void StructStringPubSubType::register_type_object_representation() StructWStringPubSubType::StructWStringPubSubType() { - setName("StructWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructWString::getMaxCdrSerializedSize()); -#else - StructWString_max_cdr_typesize; -#endif + set_name("StructWString"); + uint32_t type_size = StructWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructWString_max_key_cdr_typesize > 16 ? StructWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructWString_max_key_cdr_typesize > 16 ? StructWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructWStringPubSubType::~StructWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool StructWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool StructWStringPubSubType::deserialize( StructWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool StructWStringPubSubType::deserialize( return true; } -std::function StructWStringPubSubType::getSerializedSizeProvider( +uint32_t StructWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructWStringPubSubType::createData() + 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* StructWStringPubSubType::create_data() { return reinterpret_cast(new StructWString()); } -void StructWStringPubSubType::deleteData( +void StructWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructWStringPubSubType::getKey( +bool StructWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool StructWStringPubSubType::getKey( const StructWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void StructWStringPubSubType::register_type_object_representation() StructBoundedStringPubSubType::StructBoundedStringPubSubType() { - setName("StructBoundedString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructBoundedString::getMaxCdrSerializedSize()); -#else - StructBoundedString_max_cdr_typesize; -#endif + set_name("StructBoundedString"); + uint32_t type_size = StructBoundedString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructBoundedString_max_key_cdr_typesize > 16 ? StructBoundedString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructBoundedString_max_key_cdr_typesize > 16 ? StructBoundedString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructBoundedStringPubSubType::~StructBoundedStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructBoundedStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool StructBoundedStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructBoundedStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool StructBoundedStringPubSubType::deserialize( StructBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool StructBoundedStringPubSubType::deserialize( return true; } -std::function StructBoundedStringPubSubType::getSerializedSizeProvider( +uint32_t StructBoundedStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructBoundedStringPubSubType::createData() + 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* StructBoundedStringPubSubType::create_data() { return reinterpret_cast(new StructBoundedString()); } -void StructBoundedStringPubSubType::deleteData( +void StructBoundedStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructBoundedStringPubSubType::getKey( +bool StructBoundedStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructBoundedString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructBoundedStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool StructBoundedStringPubSubType::getKey( const StructBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructBoundedString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructBoundedString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void StructBoundedStringPubSubType::register_type_object_representation() StructBoundedWStringPubSubType::StructBoundedWStringPubSubType() { - setName("StructBoundedWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructBoundedWString::getMaxCdrSerializedSize()); -#else - StructBoundedWString_max_cdr_typesize; -#endif + set_name("StructBoundedWString"); + uint32_t type_size = StructBoundedWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructBoundedWString_max_key_cdr_typesize > 16 ? StructBoundedWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructBoundedWString_max_key_cdr_typesize > 16 ? StructBoundedWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructBoundedWStringPubSubType::~StructBoundedWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructBoundedWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool StructBoundedWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructBoundedWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool StructBoundedWStringPubSubType::deserialize( StructBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool StructBoundedWStringPubSubType::deserialize( return true; } -std::function StructBoundedWStringPubSubType::getSerializedSizeProvider( +uint32_t StructBoundedWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructBoundedWStringPubSubType::createData() + 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* StructBoundedWStringPubSubType::create_data() { return reinterpret_cast(new StructBoundedWString()); } -void StructBoundedWStringPubSubType::deleteData( +void StructBoundedWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructBoundedWStringPubSubType::getKey( +bool StructBoundedWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructBoundedWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructBoundedWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool StructBoundedWStringPubSubType::getKey( const StructBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructBoundedWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructBoundedWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void StructBoundedWStringPubSubType::register_type_object_representation() StructEnumPubSubType::StructEnumPubSubType() { - setName("StructEnum"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructEnum::getMaxCdrSerializedSize()); -#else - StructEnum_max_cdr_typesize; -#endif + set_name("StructEnum"); + uint32_t type_size = StructEnum_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructEnum_max_key_cdr_typesize > 16 ? StructEnum_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructEnum_max_key_cdr_typesize > 16 ? StructEnum_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructEnumPubSubType::~StructEnumPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructEnumPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool StructEnumPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructEnumPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool StructEnumPubSubType::deserialize( StructEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool StructEnumPubSubType::deserialize( return true; } -std::function StructEnumPubSubType::getSerializedSizeProvider( +uint32_t StructEnumPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructEnumPubSubType::createData() + 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* StructEnumPubSubType::create_data() { return reinterpret_cast(new StructEnum()); } -void StructEnumPubSubType::deleteData( +void StructEnumPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructEnumPubSubType::getKey( +bool StructEnumPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructEnum data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructEnumPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool StructEnumPubSubType::getKey( const StructEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructEnum_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructEnum_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void StructEnumPubSubType::register_type_object_representation() StructBitMaskPubSubType::StructBitMaskPubSubType() { - setName("StructBitMask"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructBitMask::getMaxCdrSerializedSize()); -#else - StructBitMask_max_cdr_typesize; -#endif + set_name("StructBitMask"); + uint32_t type_size = StructBitMask_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructBitMask_max_key_cdr_typesize > 16 ? StructBitMask_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructBitMask_max_key_cdr_typesize > 16 ? StructBitMask_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructBitMaskPubSubType::~StructBitMaskPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructBitMaskPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool StructBitMaskPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructBitMaskPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool StructBitMaskPubSubType::deserialize( StructBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool StructBitMaskPubSubType::deserialize( return true; } -std::function StructBitMaskPubSubType::getSerializedSizeProvider( +uint32_t StructBitMaskPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructBitMaskPubSubType::createData() + 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* StructBitMaskPubSubType::create_data() { return reinterpret_cast(new StructBitMask()); } -void StructBitMaskPubSubType::deleteData( +void StructBitMaskPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructBitMaskPubSubType::getKey( +bool StructBitMaskPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructBitMask data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructBitMaskPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool StructBitMaskPubSubType::getKey( const StructBitMask* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructBitMask_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructBitMask_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3700,49 +3453,42 @@ void StructBitMaskPubSubType::register_type_object_representation() StructAliasPubSubType::StructAliasPubSubType() { - setName("StructAlias"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructAlias::getMaxCdrSerializedSize()); -#else - StructAlias_max_cdr_typesize; -#endif + set_name("StructAlias"); + uint32_t type_size = StructAlias_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructAlias_max_key_cdr_typesize > 16 ? StructAlias_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructAlias_max_key_cdr_typesize > 16 ? StructAlias_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructAliasPubSubType::~StructAliasPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructAliasPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3757,16 +3503,12 @@ bool StructAliasPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructAliasPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3775,18 +3517,14 @@ bool StructAliasPubSubType::deserialize( StructAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3799,52 +3537,62 @@ bool StructAliasPubSubType::deserialize( return true; } -std::function StructAliasPubSubType::getSerializedSizeProvider( +uint32_t StructAliasPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructAliasPubSubType::createData() + 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* StructAliasPubSubType::create_data() { return reinterpret_cast(new StructAlias()); } -void StructAliasPubSubType::deleteData( +void StructAliasPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructAliasPubSubType::getKey( +bool StructAliasPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructAlias data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructAliasPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3852,35 +3600,27 @@ bool StructAliasPubSubType::getKey( const StructAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructAlias_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructAlias_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3893,49 +3633,42 @@ void StructAliasPubSubType::register_type_object_representation() StructShortArrayPubSubType::StructShortArrayPubSubType() { - setName("StructShortArray"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructShortArray::getMaxCdrSerializedSize()); -#else - StructShortArray_max_cdr_typesize; -#endif + set_name("StructShortArray"); + uint32_t type_size = StructShortArray_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructShortArray_max_key_cdr_typesize > 16 ? StructShortArray_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructShortArray_max_key_cdr_typesize > 16 ? StructShortArray_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructShortArrayPubSubType::~StructShortArrayPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructShortArrayPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3950,16 +3683,12 @@ bool StructShortArrayPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructShortArrayPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3968,18 +3697,14 @@ bool StructShortArrayPubSubType::deserialize( StructShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3992,52 +3717,62 @@ bool StructShortArrayPubSubType::deserialize( return true; } -std::function StructShortArrayPubSubType::getSerializedSizeProvider( +uint32_t StructShortArrayPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructShortArrayPubSubType::createData() + 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* StructShortArrayPubSubType::create_data() { return reinterpret_cast(new StructShortArray()); } -void StructShortArrayPubSubType::deleteData( +void StructShortArrayPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructShortArrayPubSubType::getKey( +bool StructShortArrayPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructShortArray data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructShortArrayPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4045,35 +3780,27 @@ bool StructShortArrayPubSubType::getKey( const StructShortArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructShortArray_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructShortArray_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4086,49 +3813,42 @@ void StructShortArrayPubSubType::register_type_object_representation() StructSequencePubSubType::StructSequencePubSubType() { - setName("StructSequence"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructSequence::getMaxCdrSerializedSize()); -#else - StructSequence_max_cdr_typesize; -#endif + set_name("StructSequence"); + uint32_t type_size = StructSequence_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructSequence_max_key_cdr_typesize > 16 ? StructSequence_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructSequence_max_key_cdr_typesize > 16 ? StructSequence_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructSequencePubSubType::~StructSequencePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructSequencePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4143,16 +3863,12 @@ bool StructSequencePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructSequencePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4161,18 +3877,14 @@ bool StructSequencePubSubType::deserialize( StructSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4185,52 +3897,62 @@ bool StructSequencePubSubType::deserialize( return true; } -std::function StructSequencePubSubType::getSerializedSizeProvider( +uint32_t StructSequencePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructSequencePubSubType::createData() + 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* StructSequencePubSubType::create_data() { return reinterpret_cast(new StructSequence()); } -void StructSequencePubSubType::deleteData( +void StructSequencePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructSequencePubSubType::getKey( +bool StructSequencePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructSequence data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructSequencePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4238,35 +3960,27 @@ bool StructSequencePubSubType::getKey( const StructSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructSequence_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructSequence_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4279,49 +3993,42 @@ void StructSequencePubSubType::register_type_object_representation() StructMapPubSubType::StructMapPubSubType() { - setName("StructMap"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructMap::getMaxCdrSerializedSize()); -#else - StructMap_max_cdr_typesize; -#endif + set_name("StructMap"); + uint32_t type_size = StructMap_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructMap_max_key_cdr_typesize > 16 ? StructMap_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructMap_max_key_cdr_typesize > 16 ? StructMap_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructMapPubSubType::~StructMapPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructMapPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4336,16 +4043,12 @@ bool StructMapPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructMapPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4354,18 +4057,14 @@ bool StructMapPubSubType::deserialize( StructMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4378,52 +4077,62 @@ bool StructMapPubSubType::deserialize( return true; } -std::function StructMapPubSubType::getSerializedSizeProvider( +uint32_t StructMapPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructMapPubSubType::createData() + 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* StructMapPubSubType::create_data() { return reinterpret_cast(new StructMap()); } -void StructMapPubSubType::deleteData( +void StructMapPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructMapPubSubType::getKey( +bool StructMapPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructMap data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructMapPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4431,35 +4140,27 @@ bool StructMapPubSubType::getKey( const StructMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructMap_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructMap_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4472,49 +4173,42 @@ void StructMapPubSubType::register_type_object_representation() StructUnionPubSubType::StructUnionPubSubType() { - setName("StructUnion"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructUnion::getMaxCdrSerializedSize()); -#else - StructUnion_max_cdr_typesize; -#endif + set_name("StructUnion"); + uint32_t type_size = StructUnion_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructUnion_max_key_cdr_typesize > 16 ? StructUnion_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructUnion_max_key_cdr_typesize > 16 ? StructUnion_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructUnionPubSubType::~StructUnionPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructUnionPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4529,16 +4223,12 @@ bool StructUnionPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructUnionPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4547,18 +4237,14 @@ bool StructUnionPubSubType::deserialize( StructUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4571,52 +4257,62 @@ bool StructUnionPubSubType::deserialize( return true; } -std::function StructUnionPubSubType::getSerializedSizeProvider( +uint32_t StructUnionPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructUnionPubSubType::createData() + 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* StructUnionPubSubType::create_data() { return reinterpret_cast(new StructUnion()); } -void StructUnionPubSubType::deleteData( +void StructUnionPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructUnionPubSubType::getKey( +bool StructUnionPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructUnion data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructUnionPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4624,35 +4320,27 @@ bool StructUnionPubSubType::getKey( const StructUnion* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructUnion_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructUnion_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4665,49 +4353,42 @@ void StructUnionPubSubType::register_type_object_representation() StructStructurePubSubType::StructStructurePubSubType() { - setName("StructStructure"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructStructure::getMaxCdrSerializedSize()); -#else - StructStructure_max_cdr_typesize; -#endif + set_name("StructStructure"); + uint32_t type_size = StructStructure_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructStructure_max_key_cdr_typesize > 16 ? StructStructure_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructStructure_max_key_cdr_typesize > 16 ? StructStructure_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructStructurePubSubType::~StructStructurePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructStructurePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4722,16 +4403,12 @@ bool StructStructurePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructStructurePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4740,18 +4417,14 @@ bool StructStructurePubSubType::deserialize( StructStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4764,52 +4437,62 @@ bool StructStructurePubSubType::deserialize( return true; } -std::function StructStructurePubSubType::getSerializedSizeProvider( +uint32_t StructStructurePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructStructurePubSubType::createData() + 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* StructStructurePubSubType::create_data() { return reinterpret_cast(new StructStructure()); } -void StructStructurePubSubType::deleteData( +void StructStructurePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructStructurePubSubType::getKey( +bool StructStructurePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructStructure data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructStructurePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4817,35 +4500,27 @@ bool StructStructurePubSubType::getKey( const StructStructure* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructStructure_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructStructure_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4858,49 +4533,42 @@ void StructStructurePubSubType::register_type_object_representation() StructBitsetPubSubType::StructBitsetPubSubType() { - setName("StructBitset"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructBitset::getMaxCdrSerializedSize()); -#else - StructBitset_max_cdr_typesize; -#endif + set_name("StructBitset"); + uint32_t type_size = StructBitset_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructBitset_max_key_cdr_typesize > 16 ? StructBitset_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructBitset_max_key_cdr_typesize > 16 ? StructBitset_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructBitsetPubSubType::~StructBitsetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructBitsetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4915,16 +4583,12 @@ bool StructBitsetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructBitsetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4933,18 +4597,14 @@ bool StructBitsetPubSubType::deserialize( StructBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4957,52 +4617,62 @@ bool StructBitsetPubSubType::deserialize( return true; } -std::function StructBitsetPubSubType::getSerializedSizeProvider( +uint32_t StructBitsetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructBitsetPubSubType::createData() + 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* StructBitsetPubSubType::create_data() { return reinterpret_cast(new StructBitset()); } -void StructBitsetPubSubType::deleteData( +void StructBitsetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructBitsetPubSubType::getKey( +bool StructBitsetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructBitset data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructBitsetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5010,35 +4680,27 @@ bool StructBitsetPubSubType::getKey( const StructBitset* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructBitset_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructBitset_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5051,49 +4713,42 @@ void StructBitsetPubSubType::register_type_object_representation() StructEmptyPubSubType::StructEmptyPubSubType() { - setName("StructEmpty"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructEmpty::getMaxCdrSerializedSize()); -#else - StructEmpty_max_cdr_typesize; -#endif + set_name("StructEmpty"); + uint32_t type_size = StructEmpty_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructEmpty_max_key_cdr_typesize > 16 ? StructEmpty_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructEmpty_max_key_cdr_typesize > 16 ? StructEmpty_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructEmptyPubSubType::~StructEmptyPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructEmptyPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructEmpty* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5108,16 +4763,12 @@ bool StructEmptyPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructEmptyPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5126,18 +4777,14 @@ bool StructEmptyPubSubType::deserialize( StructEmpty* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5150,52 +4797,62 @@ bool StructEmptyPubSubType::deserialize( return true; } -std::function StructEmptyPubSubType::getSerializedSizeProvider( +uint32_t StructEmptyPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructEmptyPubSubType::createData() + 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* StructEmptyPubSubType::create_data() { return reinterpret_cast(new StructEmpty()); } -void StructEmptyPubSubType::deleteData( +void StructEmptyPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructEmptyPubSubType::getKey( +bool StructEmptyPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructEmpty data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructEmptyPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5203,35 +4860,27 @@ bool StructEmptyPubSubType::getKey( const StructEmpty* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructEmpty_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructEmpty_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5244,49 +4893,42 @@ void StructEmptyPubSubType::register_type_object_representation() StructuresPubSubType::StructuresPubSubType() { - setName("Structures"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Structures::getMaxCdrSerializedSize()); -#else - Structures_max_cdr_typesize; -#endif + set_name("Structures"); + uint32_t type_size = Structures_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Structures_max_key_cdr_typesize > 16 ? Structures_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = Structures_max_key_cdr_typesize > 16 ? Structures_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructuresPubSubType::~StructuresPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructuresPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const Structures* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5301,16 +4943,12 @@ bool StructuresPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructuresPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5319,18 +4957,14 @@ bool StructuresPubSubType::deserialize( Structures* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5343,52 +4977,62 @@ bool StructuresPubSubType::deserialize( return true; } -std::function StructuresPubSubType::getSerializedSizeProvider( +uint32_t StructuresPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructuresPubSubType::createData() + 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* StructuresPubSubType::create_data() { return reinterpret_cast(new Structures()); } -void StructuresPubSubType::deleteData( +void StructuresPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructuresPubSubType::getKey( +bool StructuresPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + Structures data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructuresPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5396,35 +5040,27 @@ bool StructuresPubSubType::getKey( const Structures* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), Structures_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Structures_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5438,49 +5074,42 @@ void StructuresPubSubType::register_type_object_representation() namespace testing_1 { fooPubSubType::fooPubSubType() { - setName("testing_1::foo"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(foo::getMaxCdrSerializedSize()); - #else - testing_1_foo_max_cdr_typesize; - #endif + set_name("testing_1::foo"); + uint32_t type_size = testing_1_foo_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = testing_1_foo_max_key_cdr_typesize > 16 ? testing_1_foo_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = testing_1_foo_max_key_cdr_typesize > 16 ? testing_1_foo_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } fooPubSubType::~fooPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool fooPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const foo* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5495,16 +5124,12 @@ namespace testing_1 { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool fooPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5513,18 +5138,14 @@ namespace testing_1 { foo* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5537,52 +5158,62 @@ namespace testing_1 { return true; } - std::function fooPubSubType::getSerializedSizeProvider( + uint32_t fooPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* fooPubSubType::createData() + 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* fooPubSubType::create_data() { return reinterpret_cast(new foo()); } - void fooPubSubType::deleteData( + void fooPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool fooPubSubType::getKey( + bool fooPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + foo data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool fooPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5590,35 +5221,27 @@ namespace testing_1 { const foo* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), testing_1_foo_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || testing_1_foo_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5634,49 +5257,42 @@ namespace testing_1 { namespace testing_2 { fooPubSubType::fooPubSubType() { - setName("testing_2::foo"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(foo::getMaxCdrSerializedSize()); - #else - testing_2_foo_max_cdr_typesize; - #endif + set_name("testing_2::foo"); + uint32_t type_size = testing_2_foo_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = testing_2_foo_max_key_cdr_typesize > 16 ? testing_2_foo_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = testing_2_foo_max_key_cdr_typesize > 16 ? testing_2_foo_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } fooPubSubType::~fooPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool fooPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const foo* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 + 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); - #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5691,16 +5307,12 @@ namespace testing_2 { } // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool fooPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5709,18 +5321,14 @@ namespace testing_2 { foo* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5733,52 +5341,62 @@ namespace testing_2 { return true; } - std::function fooPubSubType::getSerializedSizeProvider( + uint32_t fooPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* fooPubSubType::createData() + 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* fooPubSubType::create_data() { return reinterpret_cast(new foo()); } - void fooPubSubType::deleteData( + void fooPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } - bool fooPubSubType::getKey( + bool fooPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) + { + if (!is_compute_key_provided) + { + return false; + } + + foo data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool fooPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5786,35 +5404,27 @@ namespace testing_2 { const foo* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), testing_2_foo_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || testing_2_foo_max_key_cdr_typesize > 16) { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5829,49 +5439,42 @@ namespace testing_2 { barPubSubType::barPubSubType() { - setName("bar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(bar::getMaxCdrSerializedSize()); -#else - bar_max_cdr_typesize; -#endif + set_name("bar"); + uint32_t type_size = bar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = bar_max_key_cdr_typesize > 16 ? bar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = bar_max_key_cdr_typesize > 16 ? bar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } barPubSubType::~barPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool barPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const bar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5886,16 +5489,12 @@ bool barPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool barPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5904,18 +5503,14 @@ bool barPubSubType::deserialize( bar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5928,52 +5523,62 @@ bool barPubSubType::deserialize( return true; } -std::function barPubSubType::getSerializedSizeProvider( +uint32_t barPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* barPubSubType::createData() + 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* barPubSubType::create_data() { return reinterpret_cast(new bar()); } -void barPubSubType::deleteData( +void barPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool barPubSubType::getKey( +bool barPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + bar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool barPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5981,35 +5586,27 @@ bool barPubSubType::getKey( const bar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), bar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || bar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6022,49 +5619,42 @@ void barPubSubType::register_type_object_representation() root1PubSubType::root1PubSubType() { - setName("root1"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(root1::getMaxCdrSerializedSize()); -#else - root1_max_cdr_typesize; -#endif + set_name("root1"); + uint32_t type_size = root1_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = root1_max_key_cdr_typesize > 16 ? root1_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = root1_max_key_cdr_typesize > 16 ? root1_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } root1PubSubType::~root1PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool root1PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const root1* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6079,16 +5669,12 @@ bool root1PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool root1PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6097,18 +5683,14 @@ bool root1PubSubType::deserialize( root1* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6121,52 +5703,62 @@ bool root1PubSubType::deserialize( return true; } -std::function root1PubSubType::getSerializedSizeProvider( +uint32_t root1PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* root1PubSubType::createData() + 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* root1PubSubType::create_data() { return reinterpret_cast(new root1()); } -void root1PubSubType::deleteData( +void root1PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool root1PubSubType::getKey( +bool root1PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + root1 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool root1PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6174,35 +5766,27 @@ bool root1PubSubType::getKey( const root1* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), root1_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || root1_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6215,49 +5799,42 @@ void root1PubSubType::register_type_object_representation() root2PubSubType::root2PubSubType() { - setName("root2"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(root2::getMaxCdrSerializedSize()); -#else - root2_max_cdr_typesize; -#endif + set_name("root2"); + uint32_t type_size = root2_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = root2_max_key_cdr_typesize > 16 ? root2_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = root2_max_key_cdr_typesize > 16 ? root2_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } root2PubSubType::~root2PubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool root2PubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const root2* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6272,16 +5849,12 @@ bool root2PubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool root2PubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6290,18 +5863,14 @@ bool root2PubSubType::deserialize( root2* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6314,52 +5883,62 @@ bool root2PubSubType::deserialize( return true; } -std::function root2PubSubType::getSerializedSizeProvider( +uint32_t root2PubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* root2PubSubType::createData() + 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* root2PubSubType::create_data() { return reinterpret_cast(new root2()); } -void root2PubSubType::deleteData( +void root2PubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool root2PubSubType::getKey( +bool root2PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + root2 data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool root2PubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6367,35 +5946,27 @@ bool root2PubSubType::getKey( const root2* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), root2_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || root2_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6408,49 +5979,42 @@ void root2PubSubType::register_type_object_representation() rootPubSubType::rootPubSubType() { - setName("root"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(root::getMaxCdrSerializedSize()); -#else - root_max_cdr_typesize; -#endif + set_name("root"); + uint32_t type_size = root_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = root_max_key_cdr_typesize > 16 ? root_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = root_max_key_cdr_typesize > 16 ? root_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } rootPubSubType::~rootPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool rootPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const root* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6465,16 +6029,12 @@ bool rootPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool rootPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6483,18 +6043,14 @@ bool rootPubSubType::deserialize( root* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6507,52 +6063,62 @@ bool rootPubSubType::deserialize( return true; } -std::function rootPubSubType::getSerializedSizeProvider( +uint32_t rootPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* rootPubSubType::createData() + 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* rootPubSubType::create_data() { return reinterpret_cast(new root()); } -void rootPubSubType::deleteData( +void rootPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool rootPubSubType::getKey( +bool rootPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + root data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool rootPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6560,35 +6126,27 @@ bool rootPubSubType::getKey( const root* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), root_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || root_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/structuresPubSubTypes.hpp b/test/dds-types-test/structuresPubSubTypes.hpp index aeac8ffe3f1..a68af1f1334 100644 --- a/test/dds-types-test/structuresPubSubTypes.hpp +++ b/test/dds-types-test/structuresPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated structures is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class StructShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class StructShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class StructShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class StructUnsignedShortPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class StructUnsignedShortPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class StructUnsignedShortPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -237,38 +217,30 @@ class StructLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -283,10 +255,6 @@ class StructLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,8 +275,10 @@ class StructLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -328,38 +298,30 @@ class StructUnsignedLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -374,10 +336,6 @@ class StructUnsignedLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -398,8 +356,10 @@ class StructUnsignedLongPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -419,38 +379,30 @@ class StructLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -465,10 +417,6 @@ class StructLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -489,8 +437,10 @@ class StructLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -510,38 +460,30 @@ class StructUnsignedLongLongPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -556,10 +498,6 @@ class StructUnsignedLongLongPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -580,8 +518,10 @@ class StructUnsignedLongLongPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -601,38 +541,30 @@ class StructFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -647,10 +579,6 @@ class StructFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -671,8 +599,10 @@ class StructFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -692,38 +622,30 @@ class StructDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -738,10 +660,6 @@ class StructDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -762,8 +680,10 @@ class StructDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -783,38 +703,30 @@ class StructLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -829,10 +741,6 @@ class StructLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -853,8 +761,10 @@ class StructLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -874,38 +784,30 @@ class StructBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -920,10 +822,6 @@ class StructBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -944,8 +842,10 @@ class StructBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -965,38 +865,30 @@ class StructOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1011,10 +903,6 @@ class StructOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1035,8 +923,10 @@ class StructOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1056,38 +946,30 @@ class StructChar8PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1102,10 +984,6 @@ class StructChar8PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1126,8 +1004,10 @@ class StructChar8PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1147,38 +1027,30 @@ class StructChar16PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1193,10 +1065,6 @@ class StructChar16PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1217,8 +1085,10 @@ class StructChar16PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1238,38 +1108,30 @@ class StructStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1284,10 +1146,6 @@ class StructStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1308,8 +1166,10 @@ class StructStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1329,38 +1189,30 @@ class StructWStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1375,10 +1227,6 @@ class StructWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1399,8 +1247,10 @@ class StructWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1420,38 +1270,30 @@ class StructBoundedStringPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1466,10 +1308,6 @@ class StructBoundedStringPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1490,8 +1328,10 @@ class StructBoundedStringPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1511,38 +1351,30 @@ class StructBoundedWStringPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1557,10 +1389,6 @@ class StructBoundedWStringPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1581,8 +1409,10 @@ class StructBoundedWStringPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1602,38 +1432,30 @@ class StructEnumPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1648,10 +1470,6 @@ class StructEnumPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1672,8 +1490,10 @@ class StructEnumPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1693,38 +1513,30 @@ class StructBitMaskPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1739,10 +1551,6 @@ class StructBitMaskPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1763,8 +1571,10 @@ class StructBitMaskPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1784,38 +1594,30 @@ class StructAliasPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1830,10 +1632,6 @@ class StructAliasPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1854,8 +1652,10 @@ class StructAliasPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1875,38 +1675,30 @@ class StructShortArrayPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1921,10 +1713,6 @@ class StructShortArrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1945,8 +1733,10 @@ class StructShortArrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1966,38 +1756,30 @@ class StructSequencePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2012,10 +1794,6 @@ class StructSequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2036,8 +1814,10 @@ class StructSequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2057,38 +1837,30 @@ class StructMapPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2103,10 +1875,6 @@ class StructMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2127,8 +1895,10 @@ class StructMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2148,38 +1918,30 @@ class StructUnionPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2194,10 +1956,6 @@ class StructUnionPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2218,8 +1976,10 @@ class StructUnionPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2239,38 +1999,30 @@ class StructStructurePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2285,10 +2037,6 @@ class StructStructurePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2309,8 +2057,10 @@ class StructStructurePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2330,38 +2080,30 @@ class StructBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2376,10 +2118,6 @@ class StructBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2400,8 +2138,10 @@ class StructBitsetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2421,38 +2161,30 @@ class StructEmptyPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2467,10 +2199,6 @@ class StructEmptyPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2491,8 +2219,10 @@ class StructEmptyPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2512,38 +2242,30 @@ class StructuresPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2558,10 +2280,6 @@ class StructuresPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2582,8 +2300,10 @@ class StructuresPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; namespace testing_1 @@ -2605,38 +2325,30 @@ namespace testing_1 eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2651,10 +2363,6 @@ namespace testing_1 #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2675,8 +2383,10 @@ namespace testing_1 #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace testing_1 @@ -2699,38 +2409,30 @@ namespace testing_2 eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2745,10 +2447,6 @@ namespace testing_2 #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2769,8 +2467,10 @@ namespace testing_2 #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; + private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; } // namespace testing_2 @@ -2791,38 +2491,30 @@ class barPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2837,10 +2529,6 @@ class barPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2861,8 +2549,10 @@ class barPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2882,38 +2572,30 @@ class root1PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2928,10 +2610,6 @@ class root1PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2952,8 +2630,10 @@ class root1PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2973,38 +2653,30 @@ class root2PubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3019,10 +2691,6 @@ class root2PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3043,8 +2711,10 @@ class root2PubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3064,38 +2734,30 @@ class rootPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3110,10 +2772,6 @@ class rootPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3134,8 +2792,10 @@ class rootPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/dds-types-test/unionsPubSubTypes.cxx b/test/dds-types-test/unionsPubSubTypes.cxx index 6e430d2bdae..e6a15fea142 100644 --- a/test/dds-types-test/unionsPubSubTypes.cxx +++ b/test/dds-types-test/unionsPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; UnionShortPubSubType::UnionShortPubSubType() { - setName("UnionShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionShort::getMaxCdrSerializedSize()); -#else - UnionShort_max_cdr_typesize; -#endif + set_name("UnionShort"); + uint32_t type_size = UnionShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionShort_max_key_cdr_typesize > 16 ? UnionShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionShort_max_key_cdr_typesize > 16 ? UnionShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionShortPubSubType::~UnionShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool UnionShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool UnionShortPubSubType::deserialize( UnionShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool UnionShortPubSubType::deserialize( return true; } -std::function UnionShortPubSubType::getSerializedSizeProvider( +uint32_t UnionShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionShortPubSubType::createData() + 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* UnionShortPubSubType::create_data() { return reinterpret_cast(new UnionShort()); } -void UnionShortPubSubType::deleteData( +void UnionShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionShortPubSubType::getKey( +bool UnionShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool UnionShortPubSubType::getKey( const UnionShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void UnionShortPubSubType::register_type_object_representation() UnionUShortPubSubType::UnionUShortPubSubType() { - setName("UnionUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionUShort::getMaxCdrSerializedSize()); -#else - UnionUShort_max_cdr_typesize; -#endif + set_name("UnionUShort"); + uint32_t type_size = UnionUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionUShort_max_key_cdr_typesize > 16 ? UnionUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionUShort_max_key_cdr_typesize > 16 ? UnionUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionUShortPubSubType::~UnionUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool UnionUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool UnionUShortPubSubType::deserialize( UnionUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool UnionUShortPubSubType::deserialize( return true; } -std::function UnionUShortPubSubType::getSerializedSizeProvider( +uint32_t UnionUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionUShortPubSubType::createData() + 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* UnionUShortPubSubType::create_data() { return reinterpret_cast(new UnionUShort()); } -void UnionUShortPubSubType::deleteData( +void UnionUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionUShortPubSubType::getKey( +bool UnionUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool UnionUShortPubSubType::getKey( const UnionUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void UnionUShortPubSubType::register_type_object_representation() UnionLongPubSubType::UnionLongPubSubType() { - setName("UnionLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionLong::getMaxCdrSerializedSize()); -#else - UnionLong_max_cdr_typesize; -#endif + set_name("UnionLong"); + uint32_t type_size = UnionLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionLong_max_key_cdr_typesize > 16 ? UnionLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionLong_max_key_cdr_typesize > 16 ? UnionLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionLongPubSubType::~UnionLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool UnionLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool UnionLongPubSubType::deserialize( UnionLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool UnionLongPubSubType::deserialize( return true; } -std::function UnionLongPubSubType::getSerializedSizeProvider( +uint32_t UnionLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionLongPubSubType::createData() + 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* UnionLongPubSubType::create_data() { return reinterpret_cast(new UnionLong()); } -void UnionLongPubSubType::deleteData( +void UnionLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionLongPubSubType::getKey( +bool UnionLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool UnionLongPubSubType::getKey( const UnionLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void UnionLongPubSubType::register_type_object_representation() UnionULongPubSubType::UnionULongPubSubType() { - setName("UnionULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionULong::getMaxCdrSerializedSize()); -#else - UnionULong_max_cdr_typesize; -#endif + set_name("UnionULong"); + uint32_t type_size = UnionULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionULong_max_key_cdr_typesize > 16 ? UnionULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionULong_max_key_cdr_typesize > 16 ? UnionULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionULongPubSubType::~UnionULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool UnionULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool UnionULongPubSubType::deserialize( UnionULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool UnionULongPubSubType::deserialize( return true; } -std::function UnionULongPubSubType::getSerializedSizeProvider( +uint32_t UnionULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionULongPubSubType::createData() + 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* UnionULongPubSubType::create_data() { return reinterpret_cast(new UnionULong()); } -void UnionULongPubSubType::deleteData( +void UnionULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionULongPubSubType::getKey( +bool UnionULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool UnionULongPubSubType::getKey( const UnionULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -805,49 +753,42 @@ void UnionULongPubSubType::register_type_object_representation() UnionLongLongPubSubType::UnionLongLongPubSubType() { - setName("UnionLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionLongLong::getMaxCdrSerializedSize()); -#else - UnionLongLong_max_cdr_typesize; -#endif + set_name("UnionLongLong"); + uint32_t type_size = UnionLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionLongLong_max_key_cdr_typesize > 16 ? UnionLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionLongLong_max_key_cdr_typesize > 16 ? UnionLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionLongLongPubSubType::~UnionLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -862,16 +803,12 @@ bool UnionLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -880,18 +817,14 @@ bool UnionLongLongPubSubType::deserialize( UnionLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -904,52 +837,62 @@ bool UnionLongLongPubSubType::deserialize( return true; } -std::function UnionLongLongPubSubType::getSerializedSizeProvider( +uint32_t UnionLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionLongLongPubSubType::createData() + 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* UnionLongLongPubSubType::create_data() { return reinterpret_cast(new UnionLongLong()); } -void UnionLongLongPubSubType::deleteData( +void UnionLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionLongLongPubSubType::getKey( +bool UnionLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -957,35 +900,27 @@ bool UnionLongLongPubSubType::getKey( const UnionLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -998,49 +933,42 @@ void UnionLongLongPubSubType::register_type_object_representation() UnionULongLongPubSubType::UnionULongLongPubSubType() { - setName("UnionULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionULongLong::getMaxCdrSerializedSize()); -#else - UnionULongLong_max_cdr_typesize; -#endif + set_name("UnionULongLong"); + uint32_t type_size = UnionULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionULongLong_max_key_cdr_typesize > 16 ? UnionULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionULongLong_max_key_cdr_typesize > 16 ? UnionULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionULongLongPubSubType::~UnionULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1055,16 +983,12 @@ bool UnionULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1073,18 +997,14 @@ bool UnionULongLongPubSubType::deserialize( UnionULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1097,52 +1017,62 @@ bool UnionULongLongPubSubType::deserialize( return true; } -std::function UnionULongLongPubSubType::getSerializedSizeProvider( +uint32_t UnionULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionULongLongPubSubType::createData() + 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* UnionULongLongPubSubType::create_data() { return reinterpret_cast(new UnionULongLong()); } -void UnionULongLongPubSubType::deleteData( +void UnionULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionULongLongPubSubType::getKey( +bool UnionULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1150,35 +1080,27 @@ bool UnionULongLongPubSubType::getKey( const UnionULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1191,49 +1113,42 @@ void UnionULongLongPubSubType::register_type_object_representation() UnionFloatPubSubType::UnionFloatPubSubType() { - setName("UnionFloat"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionFloat::getMaxCdrSerializedSize()); -#else - UnionFloat_max_cdr_typesize; -#endif + set_name("UnionFloat"); + uint32_t type_size = UnionFloat_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionFloat_max_key_cdr_typesize > 16 ? UnionFloat_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionFloat_max_key_cdr_typesize > 16 ? UnionFloat_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionFloatPubSubType::~UnionFloatPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionFloatPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1248,16 +1163,12 @@ bool UnionFloatPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionFloatPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1266,18 +1177,14 @@ bool UnionFloatPubSubType::deserialize( UnionFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1290,52 +1197,62 @@ bool UnionFloatPubSubType::deserialize( return true; } -std::function UnionFloatPubSubType::getSerializedSizeProvider( +uint32_t UnionFloatPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionFloatPubSubType::createData() + 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* UnionFloatPubSubType::create_data() { return reinterpret_cast(new UnionFloat()); } -void UnionFloatPubSubType::deleteData( +void UnionFloatPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionFloatPubSubType::getKey( +bool UnionFloatPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionFloat data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionFloatPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1343,35 +1260,27 @@ bool UnionFloatPubSubType::getKey( const UnionFloat* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionFloat_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionFloat_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1384,49 +1293,42 @@ void UnionFloatPubSubType::register_type_object_representation() UnionDoublePubSubType::UnionDoublePubSubType() { - setName("UnionDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDouble::getMaxCdrSerializedSize()); -#else - UnionDouble_max_cdr_typesize; -#endif + set_name("UnionDouble"); + uint32_t type_size = UnionDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDouble_max_key_cdr_typesize > 16 ? UnionDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDouble_max_key_cdr_typesize > 16 ? UnionDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDoublePubSubType::~UnionDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1441,16 +1343,12 @@ bool UnionDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1459,18 +1357,14 @@ bool UnionDoublePubSubType::deserialize( UnionDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1483,52 +1377,62 @@ bool UnionDoublePubSubType::deserialize( return true; } -std::function UnionDoublePubSubType::getSerializedSizeProvider( +uint32_t UnionDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDoublePubSubType::createData() + 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* UnionDoublePubSubType::create_data() { return reinterpret_cast(new UnionDouble()); } -void UnionDoublePubSubType::deleteData( +void UnionDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDoublePubSubType::getKey( +bool UnionDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1536,35 +1440,27 @@ bool UnionDoublePubSubType::getKey( const UnionDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1577,49 +1473,42 @@ void UnionDoublePubSubType::register_type_object_representation() UnionLongDoublePubSubType::UnionLongDoublePubSubType() { - setName("UnionLongDouble"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionLongDouble::getMaxCdrSerializedSize()); -#else - UnionLongDouble_max_cdr_typesize; -#endif + set_name("UnionLongDouble"); + uint32_t type_size = UnionLongDouble_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionLongDouble_max_key_cdr_typesize > 16 ? UnionLongDouble_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionLongDouble_max_key_cdr_typesize > 16 ? UnionLongDouble_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionLongDoublePubSubType::~UnionLongDoublePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionLongDoublePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1634,16 +1523,12 @@ bool UnionLongDoublePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionLongDoublePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1652,18 +1537,14 @@ bool UnionLongDoublePubSubType::deserialize( UnionLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1676,52 +1557,62 @@ bool UnionLongDoublePubSubType::deserialize( return true; } -std::function UnionLongDoublePubSubType::getSerializedSizeProvider( +uint32_t UnionLongDoublePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionLongDoublePubSubType::createData() + 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* UnionLongDoublePubSubType::create_data() { return reinterpret_cast(new UnionLongDouble()); } -void UnionLongDoublePubSubType::deleteData( +void UnionLongDoublePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionLongDoublePubSubType::getKey( +bool UnionLongDoublePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionLongDouble data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionLongDoublePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1729,35 +1620,27 @@ bool UnionLongDoublePubSubType::getKey( const UnionLongDouble* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionLongDouble_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionLongDouble_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1770,49 +1653,42 @@ void UnionLongDoublePubSubType::register_type_object_representation() UnionBooleanPubSubType::UnionBooleanPubSubType() { - setName("UnionBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionBoolean::getMaxCdrSerializedSize()); -#else - UnionBoolean_max_cdr_typesize; -#endif + set_name("UnionBoolean"); + uint32_t type_size = UnionBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionBoolean_max_key_cdr_typesize > 16 ? UnionBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionBoolean_max_key_cdr_typesize > 16 ? UnionBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionBooleanPubSubType::~UnionBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -1827,16 +1703,12 @@ bool UnionBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -1845,18 +1717,14 @@ bool UnionBooleanPubSubType::deserialize( UnionBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -1869,52 +1737,62 @@ bool UnionBooleanPubSubType::deserialize( return true; } -std::function UnionBooleanPubSubType::getSerializedSizeProvider( +uint32_t UnionBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionBooleanPubSubType::createData() + 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* UnionBooleanPubSubType::create_data() { return reinterpret_cast(new UnionBoolean()); } -void UnionBooleanPubSubType::deleteData( +void UnionBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionBooleanPubSubType::getKey( +bool UnionBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -1922,35 +1800,27 @@ bool UnionBooleanPubSubType::getKey( const UnionBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -1963,49 +1833,42 @@ void UnionBooleanPubSubType::register_type_object_representation() UnionOctetPubSubType::UnionOctetPubSubType() { - setName("UnionOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionOctet::getMaxCdrSerializedSize()); -#else - UnionOctet_max_cdr_typesize; -#endif + set_name("UnionOctet"); + uint32_t type_size = UnionOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionOctet_max_key_cdr_typesize > 16 ? UnionOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionOctet_max_key_cdr_typesize > 16 ? UnionOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionOctetPubSubType::~UnionOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2020,16 +1883,12 @@ bool UnionOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2038,18 +1897,14 @@ bool UnionOctetPubSubType::deserialize( UnionOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2062,52 +1917,62 @@ bool UnionOctetPubSubType::deserialize( return true; } -std::function UnionOctetPubSubType::getSerializedSizeProvider( +uint32_t UnionOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionOctetPubSubType::createData() + 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* UnionOctetPubSubType::create_data() { return reinterpret_cast(new UnionOctet()); } -void UnionOctetPubSubType::deleteData( +void UnionOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionOctetPubSubType::getKey( +bool UnionOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2115,35 +1980,27 @@ bool UnionOctetPubSubType::getKey( const UnionOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2156,49 +2013,42 @@ void UnionOctetPubSubType::register_type_object_representation() UnionCharPubSubType::UnionCharPubSubType() { - setName("UnionChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionChar::getMaxCdrSerializedSize()); -#else - UnionChar_max_cdr_typesize; -#endif + set_name("UnionChar"); + uint32_t type_size = UnionChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionChar_max_key_cdr_typesize > 16 ? UnionChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionChar_max_key_cdr_typesize > 16 ? UnionChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionCharPubSubType::~UnionCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2213,16 +2063,12 @@ bool UnionCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2231,18 +2077,14 @@ bool UnionCharPubSubType::deserialize( UnionChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2255,52 +2097,62 @@ bool UnionCharPubSubType::deserialize( return true; } -std::function UnionCharPubSubType::getSerializedSizeProvider( +uint32_t UnionCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionCharPubSubType::createData() + 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* UnionCharPubSubType::create_data() { return reinterpret_cast(new UnionChar()); } -void UnionCharPubSubType::deleteData( +void UnionCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionCharPubSubType::getKey( +bool UnionCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2308,35 +2160,27 @@ bool UnionCharPubSubType::getKey( const UnionChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2349,49 +2193,42 @@ void UnionCharPubSubType::register_type_object_representation() UnionWCharPubSubType::UnionWCharPubSubType() { - setName("UnionWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionWChar::getMaxCdrSerializedSize()); -#else - UnionWChar_max_cdr_typesize; -#endif + set_name("UnionWChar"); + uint32_t type_size = UnionWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionWChar_max_key_cdr_typesize > 16 ? UnionWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionWChar_max_key_cdr_typesize > 16 ? UnionWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionWCharPubSubType::~UnionWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2406,16 +2243,12 @@ bool UnionWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2424,18 +2257,14 @@ bool UnionWCharPubSubType::deserialize( UnionWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2448,88 +2277,90 @@ bool UnionWCharPubSubType::deserialize( return true; } -std::function UnionWCharPubSubType::getSerializedSizeProvider( +uint32_t UnionWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionWCharPubSubType::createData() + 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* UnionWCharPubSubType::create_data() { return reinterpret_cast(new UnionWChar()); } -void UnionWCharPubSubType::deleteData( +void UnionWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionWCharPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, +bool UnionWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - const UnionWChar* p_type = static_cast(data); + UnionWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - UnionWChar_max_key_cdr_typesize); + return false; +} + +bool UnionWCharPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const UnionWChar* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + UnionWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2542,49 +2373,42 @@ void UnionWCharPubSubType::register_type_object_representation() UnionStringPubSubType::UnionStringPubSubType() { - setName("UnionString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionString::getMaxCdrSerializedSize()); -#else - UnionString_max_cdr_typesize; -#endif + set_name("UnionString"); + uint32_t type_size = UnionString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionString_max_key_cdr_typesize > 16 ? UnionString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionString_max_key_cdr_typesize > 16 ? UnionString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionStringPubSubType::~UnionStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2599,16 +2423,12 @@ bool UnionStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2617,18 +2437,14 @@ bool UnionStringPubSubType::deserialize( UnionString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2641,52 +2457,62 @@ bool UnionStringPubSubType::deserialize( return true; } -std::function UnionStringPubSubType::getSerializedSizeProvider( +uint32_t UnionStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionStringPubSubType::createData() + 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* UnionStringPubSubType::create_data() { return reinterpret_cast(new UnionString()); } -void UnionStringPubSubType::deleteData( +void UnionStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionStringPubSubType::getKey( +bool UnionStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2694,35 +2520,27 @@ bool UnionStringPubSubType::getKey( const UnionString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2735,49 +2553,42 @@ void UnionStringPubSubType::register_type_object_representation() UnionWStringPubSubType::UnionWStringPubSubType() { - setName("UnionWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionWString::getMaxCdrSerializedSize()); -#else - UnionWString_max_cdr_typesize; -#endif + set_name("UnionWString"); + uint32_t type_size = UnionWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionWString_max_key_cdr_typesize > 16 ? UnionWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionWString_max_key_cdr_typesize > 16 ? UnionWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionWStringPubSubType::~UnionWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2792,16 +2603,12 @@ bool UnionWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -2810,18 +2617,14 @@ bool UnionWStringPubSubType::deserialize( UnionWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -2834,52 +2637,62 @@ bool UnionWStringPubSubType::deserialize( return true; } -std::function UnionWStringPubSubType::getSerializedSizeProvider( +uint32_t UnionWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionWStringPubSubType::createData() + 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* UnionWStringPubSubType::create_data() { return reinterpret_cast(new UnionWString()); } -void UnionWStringPubSubType::deleteData( +void UnionWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionWStringPubSubType::getKey( +bool UnionWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -2887,35 +2700,27 @@ bool UnionWStringPubSubType::getKey( const UnionWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -2928,49 +2733,42 @@ void UnionWStringPubSubType::register_type_object_representation() UnionBoundedStringPubSubType::UnionBoundedStringPubSubType() { - setName("UnionBoundedString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionBoundedString::getMaxCdrSerializedSize()); -#else - UnionBoundedString_max_cdr_typesize; -#endif + set_name("UnionBoundedString"); + uint32_t type_size = UnionBoundedString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionBoundedString_max_key_cdr_typesize > 16 ? UnionBoundedString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionBoundedString_max_key_cdr_typesize > 16 ? UnionBoundedString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionBoundedStringPubSubType::~UnionBoundedStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionBoundedStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -2985,16 +2783,12 @@ bool UnionBoundedStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionBoundedStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3003,18 +2797,14 @@ bool UnionBoundedStringPubSubType::deserialize( UnionBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3027,52 +2817,62 @@ bool UnionBoundedStringPubSubType::deserialize( return true; } -std::function UnionBoundedStringPubSubType::getSerializedSizeProvider( +uint32_t UnionBoundedStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionBoundedStringPubSubType::createData() + 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* UnionBoundedStringPubSubType::create_data() { return reinterpret_cast(new UnionBoundedString()); } -void UnionBoundedStringPubSubType::deleteData( +void UnionBoundedStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionBoundedStringPubSubType::getKey( +bool UnionBoundedStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionBoundedString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionBoundedStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3080,35 +2880,27 @@ bool UnionBoundedStringPubSubType::getKey( const UnionBoundedString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionBoundedString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionBoundedString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3121,49 +2913,42 @@ void UnionBoundedStringPubSubType::register_type_object_representation() UnionBoundedWStringPubSubType::UnionBoundedWStringPubSubType() { - setName("UnionBoundedWString"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionBoundedWString::getMaxCdrSerializedSize()); -#else - UnionBoundedWString_max_cdr_typesize; -#endif + set_name("UnionBoundedWString"); + uint32_t type_size = UnionBoundedWString_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionBoundedWString_max_key_cdr_typesize > 16 ? UnionBoundedWString_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionBoundedWString_max_key_cdr_typesize > 16 ? UnionBoundedWString_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionBoundedWStringPubSubType::~UnionBoundedWStringPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionBoundedWStringPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3178,16 +2963,12 @@ bool UnionBoundedWStringPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionBoundedWStringPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3196,18 +2977,14 @@ bool UnionBoundedWStringPubSubType::deserialize( UnionBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3220,52 +2997,62 @@ bool UnionBoundedWStringPubSubType::deserialize( return true; } -std::function UnionBoundedWStringPubSubType::getSerializedSizeProvider( +uint32_t UnionBoundedWStringPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionBoundedWStringPubSubType::createData() + 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* UnionBoundedWStringPubSubType::create_data() { return reinterpret_cast(new UnionBoundedWString()); } -void UnionBoundedWStringPubSubType::deleteData( +void UnionBoundedWStringPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionBoundedWStringPubSubType::getKey( +bool UnionBoundedWStringPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionBoundedWString data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionBoundedWStringPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3273,35 +3060,27 @@ bool UnionBoundedWStringPubSubType::getKey( const UnionBoundedWString* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionBoundedWString_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionBoundedWString_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3314,49 +3093,42 @@ void UnionBoundedWStringPubSubType::register_type_object_representation() UnionInnerEnumHelperPubSubType::UnionInnerEnumHelperPubSubType() { - setName("UnionInnerEnumHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionInnerEnumHelper::getMaxCdrSerializedSize()); -#else - UnionInnerEnumHelper_max_cdr_typesize; -#endif + set_name("UnionInnerEnumHelper"); + uint32_t type_size = UnionInnerEnumHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionInnerEnumHelper_max_key_cdr_typesize > 16 ? UnionInnerEnumHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionInnerEnumHelper_max_key_cdr_typesize > 16 ? UnionInnerEnumHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionInnerEnumHelperPubSubType::~UnionInnerEnumHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionInnerEnumHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3371,16 +3143,12 @@ bool UnionInnerEnumHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionInnerEnumHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3389,18 +3157,14 @@ bool UnionInnerEnumHelperPubSubType::deserialize( UnionInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3413,52 +3177,62 @@ bool UnionInnerEnumHelperPubSubType::deserialize( return true; } -std::function UnionInnerEnumHelperPubSubType::getSerializedSizeProvider( +uint32_t UnionInnerEnumHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionInnerEnumHelperPubSubType::createData() + 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* UnionInnerEnumHelperPubSubType::create_data() { return reinterpret_cast(new UnionInnerEnumHelper()); } -void UnionInnerEnumHelperPubSubType::deleteData( +void UnionInnerEnumHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionInnerEnumHelperPubSubType::getKey( +bool UnionInnerEnumHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionInnerEnumHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionInnerEnumHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3466,35 +3240,27 @@ bool UnionInnerEnumHelperPubSubType::getKey( const UnionInnerEnumHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionInnerEnumHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionInnerEnumHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3507,49 +3273,42 @@ void UnionInnerEnumHelperPubSubType::register_type_object_representation() UnionInnerBitMaskHelperPubSubType::UnionInnerBitMaskHelperPubSubType() { - setName("UnionInnerBitMaskHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionInnerBitMaskHelper::getMaxCdrSerializedSize()); -#else - UnionInnerBitMaskHelper_max_cdr_typesize; -#endif + set_name("UnionInnerBitMaskHelper"); + uint32_t type_size = UnionInnerBitMaskHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionInnerBitMaskHelper_max_key_cdr_typesize > 16 ? UnionInnerBitMaskHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionInnerBitMaskHelper_max_key_cdr_typesize > 16 ? UnionInnerBitMaskHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionInnerBitMaskHelperPubSubType::~UnionInnerBitMaskHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionInnerBitMaskHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3564,16 +3323,12 @@ bool UnionInnerBitMaskHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionInnerBitMaskHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3582,18 +3337,14 @@ bool UnionInnerBitMaskHelperPubSubType::deserialize( UnionInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3606,52 +3357,62 @@ bool UnionInnerBitMaskHelperPubSubType::deserialize( return true; } -std::function UnionInnerBitMaskHelperPubSubType::getSerializedSizeProvider( +uint32_t UnionInnerBitMaskHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionInnerBitMaskHelperPubSubType::createData() + 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* UnionInnerBitMaskHelperPubSubType::create_data() { return reinterpret_cast(new UnionInnerBitMaskHelper()); } -void UnionInnerBitMaskHelperPubSubType::deleteData( +void UnionInnerBitMaskHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionInnerBitMaskHelperPubSubType::getKey( +bool UnionInnerBitMaskHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionInnerBitMaskHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionInnerBitMaskHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3659,35 +3420,27 @@ bool UnionInnerBitMaskHelperPubSubType::getKey( const UnionInnerBitMaskHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionInnerBitMaskHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionInnerBitMaskHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3700,49 +3453,42 @@ void UnionInnerBitMaskHelperPubSubType::register_type_object_representation() UnionInnerAliasHelperPubSubType::UnionInnerAliasHelperPubSubType() { - setName("UnionInnerAliasHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionInnerAliasHelper::getMaxCdrSerializedSize()); -#else - UnionInnerAliasHelper_max_cdr_typesize; -#endif + set_name("UnionInnerAliasHelper"); + uint32_t type_size = UnionInnerAliasHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionInnerAliasHelper_max_key_cdr_typesize > 16 ? UnionInnerAliasHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionInnerAliasHelper_max_key_cdr_typesize > 16 ? UnionInnerAliasHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionInnerAliasHelperPubSubType::~UnionInnerAliasHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionInnerAliasHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3757,16 +3503,12 @@ bool UnionInnerAliasHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionInnerAliasHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3775,18 +3517,14 @@ bool UnionInnerAliasHelperPubSubType::deserialize( UnionInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3799,52 +3537,62 @@ bool UnionInnerAliasHelperPubSubType::deserialize( return true; } -std::function UnionInnerAliasHelperPubSubType::getSerializedSizeProvider( +uint32_t UnionInnerAliasHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionInnerAliasHelperPubSubType::createData() + 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* UnionInnerAliasHelperPubSubType::create_data() { return reinterpret_cast(new UnionInnerAliasHelper()); } -void UnionInnerAliasHelperPubSubType::deleteData( +void UnionInnerAliasHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionInnerAliasHelperPubSubType::getKey( +bool UnionInnerAliasHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionInnerAliasHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionInnerAliasHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -3852,35 +3600,27 @@ bool UnionInnerAliasHelperPubSubType::getKey( const UnionInnerAliasHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionInnerAliasHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionInnerAliasHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -3893,49 +3633,42 @@ void UnionInnerAliasHelperPubSubType::register_type_object_representation() UnionArrayPubSubType::UnionArrayPubSubType() { - setName("UnionArray"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionArray::getMaxCdrSerializedSize()); -#else - UnionArray_max_cdr_typesize; -#endif + set_name("UnionArray"); + uint32_t type_size = UnionArray_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionArray_max_key_cdr_typesize > 16 ? UnionArray_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionArray_max_key_cdr_typesize > 16 ? UnionArray_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionArrayPubSubType::~UnionArrayPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionArrayPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -3950,16 +3683,12 @@ bool UnionArrayPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionArrayPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -3968,18 +3697,14 @@ bool UnionArrayPubSubType::deserialize( UnionArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -3992,52 +3717,62 @@ bool UnionArrayPubSubType::deserialize( return true; } -std::function UnionArrayPubSubType::getSerializedSizeProvider( +uint32_t UnionArrayPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionArrayPubSubType::createData() + 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* UnionArrayPubSubType::create_data() { return reinterpret_cast(new UnionArray()); } -void UnionArrayPubSubType::deleteData( +void UnionArrayPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionArrayPubSubType::getKey( +bool UnionArrayPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionArray data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionArrayPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4045,35 +3780,27 @@ bool UnionArrayPubSubType::getKey( const UnionArray* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionArray_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionArray_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4086,49 +3813,42 @@ void UnionArrayPubSubType::register_type_object_representation() UnionSequencePubSubType::UnionSequencePubSubType() { - setName("UnionSequence"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionSequence::getMaxCdrSerializedSize()); -#else - UnionSequence_max_cdr_typesize; -#endif + set_name("UnionSequence"); + uint32_t type_size = UnionSequence_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionSequence_max_key_cdr_typesize > 16 ? UnionSequence_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionSequence_max_key_cdr_typesize > 16 ? UnionSequence_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionSequencePubSubType::~UnionSequencePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionSequencePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4143,16 +3863,12 @@ bool UnionSequencePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionSequencePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4161,18 +3877,14 @@ bool UnionSequencePubSubType::deserialize( UnionSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4185,52 +3897,62 @@ bool UnionSequencePubSubType::deserialize( return true; } -std::function UnionSequencePubSubType::getSerializedSizeProvider( +uint32_t UnionSequencePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionSequencePubSubType::createData() + 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* UnionSequencePubSubType::create_data() { return reinterpret_cast(new UnionSequence()); } -void UnionSequencePubSubType::deleteData( +void UnionSequencePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionSequencePubSubType::getKey( +bool UnionSequencePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionSequence data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionSequencePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4238,35 +3960,27 @@ bool UnionSequencePubSubType::getKey( const UnionSequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionSequence_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionSequence_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4279,49 +3993,42 @@ void UnionSequencePubSubType::register_type_object_representation() UnionMapPubSubType::UnionMapPubSubType() { - setName("UnionMap"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionMap::getMaxCdrSerializedSize()); -#else - UnionMap_max_cdr_typesize; -#endif + set_name("UnionMap"); + uint32_t type_size = UnionMap_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionMap_max_key_cdr_typesize > 16 ? UnionMap_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionMap_max_key_cdr_typesize > 16 ? UnionMap_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionMapPubSubType::~UnionMapPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionMapPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4336,16 +4043,12 @@ bool UnionMapPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionMapPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4354,18 +4057,14 @@ bool UnionMapPubSubType::deserialize( UnionMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4378,52 +4077,62 @@ bool UnionMapPubSubType::deserialize( return true; } -std::function UnionMapPubSubType::getSerializedSizeProvider( +uint32_t UnionMapPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionMapPubSubType::createData() + 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* UnionMapPubSubType::create_data() { return reinterpret_cast(new UnionMap()); } -void UnionMapPubSubType::deleteData( +void UnionMapPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionMapPubSubType::getKey( +bool UnionMapPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionMap data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionMapPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4431,35 +4140,27 @@ bool UnionMapPubSubType::getKey( const UnionMap* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionMap_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionMap_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4472,49 +4173,42 @@ void UnionMapPubSubType::register_type_object_representation() UnionInnerUnionHelperPubSubType::UnionInnerUnionHelperPubSubType() { - setName("UnionInnerUnionHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionInnerUnionHelper::getMaxCdrSerializedSize()); -#else - UnionInnerUnionHelper_max_cdr_typesize; -#endif + set_name("UnionInnerUnionHelper"); + uint32_t type_size = UnionInnerUnionHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionInnerUnionHelper_max_key_cdr_typesize > 16 ? UnionInnerUnionHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionInnerUnionHelper_max_key_cdr_typesize > 16 ? UnionInnerUnionHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionInnerUnionHelperPubSubType::~UnionInnerUnionHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionInnerUnionHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4529,16 +4223,12 @@ bool UnionInnerUnionHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionInnerUnionHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4547,18 +4237,14 @@ bool UnionInnerUnionHelperPubSubType::deserialize( UnionInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4571,52 +4257,62 @@ bool UnionInnerUnionHelperPubSubType::deserialize( return true; } -std::function UnionInnerUnionHelperPubSubType::getSerializedSizeProvider( +uint32_t UnionInnerUnionHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionInnerUnionHelperPubSubType::createData() + 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* UnionInnerUnionHelperPubSubType::create_data() { return reinterpret_cast(new UnionInnerUnionHelper()); } -void UnionInnerUnionHelperPubSubType::deleteData( +void UnionInnerUnionHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionInnerUnionHelperPubSubType::getKey( +bool UnionInnerUnionHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionInnerUnionHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionInnerUnionHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4624,35 +4320,27 @@ bool UnionInnerUnionHelperPubSubType::getKey( const UnionInnerUnionHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionInnerUnionHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionInnerUnionHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4665,49 +4353,42 @@ void UnionInnerUnionHelperPubSubType::register_type_object_representation() UnionInnerStructureHelperPubSubType::UnionInnerStructureHelperPubSubType() { - setName("UnionInnerStructureHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionInnerStructureHelper::getMaxCdrSerializedSize()); -#else - UnionInnerStructureHelper_max_cdr_typesize; -#endif + set_name("UnionInnerStructureHelper"); + uint32_t type_size = UnionInnerStructureHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionInnerStructureHelper_max_key_cdr_typesize > 16 ? UnionInnerStructureHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionInnerStructureHelper_max_key_cdr_typesize > 16 ? UnionInnerStructureHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionInnerStructureHelperPubSubType::~UnionInnerStructureHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionInnerStructureHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4722,16 +4403,12 @@ bool UnionInnerStructureHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionInnerStructureHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4740,18 +4417,14 @@ bool UnionInnerStructureHelperPubSubType::deserialize( UnionInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4764,52 +4437,62 @@ bool UnionInnerStructureHelperPubSubType::deserialize( return true; } -std::function UnionInnerStructureHelperPubSubType::getSerializedSizeProvider( +uint32_t UnionInnerStructureHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionInnerStructureHelperPubSubType::createData() + 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* UnionInnerStructureHelperPubSubType::create_data() { return reinterpret_cast(new UnionInnerStructureHelper()); } -void UnionInnerStructureHelperPubSubType::deleteData( +void UnionInnerStructureHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionInnerStructureHelperPubSubType::getKey( +bool UnionInnerStructureHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionInnerStructureHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionInnerStructureHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -4817,35 +4500,27 @@ bool UnionInnerStructureHelperPubSubType::getKey( const UnionInnerStructureHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionInnerStructureHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionInnerStructureHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -4858,49 +4533,42 @@ void UnionInnerStructureHelperPubSubType::register_type_object_representation() UnionInnerBitsetHelperPubSubType::UnionInnerBitsetHelperPubSubType() { - setName("UnionInnerBitsetHelper"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionInnerBitsetHelper::getMaxCdrSerializedSize()); -#else - UnionInnerBitsetHelper_max_cdr_typesize; -#endif + set_name("UnionInnerBitsetHelper"); + uint32_t type_size = UnionInnerBitsetHelper_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionInnerBitsetHelper_max_key_cdr_typesize > 16 ? UnionInnerBitsetHelper_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionInnerBitsetHelper_max_key_cdr_typesize > 16 ? UnionInnerBitsetHelper_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionInnerBitsetHelperPubSubType::~UnionInnerBitsetHelperPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionInnerBitsetHelperPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -4915,16 +4583,12 @@ bool UnionInnerBitsetHelperPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionInnerBitsetHelperPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -4933,18 +4597,14 @@ bool UnionInnerBitsetHelperPubSubType::deserialize( UnionInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -4957,52 +4617,62 @@ bool UnionInnerBitsetHelperPubSubType::deserialize( return true; } -std::function UnionInnerBitsetHelperPubSubType::getSerializedSizeProvider( +uint32_t UnionInnerBitsetHelperPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionInnerBitsetHelperPubSubType::createData() -{ - return reinterpret_cast(new UnionInnerBitsetHelper()); -} - -void UnionInnerBitsetHelperPubSubType::deleteData( + 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* UnionInnerBitsetHelperPubSubType::create_data() +{ + return reinterpret_cast(new UnionInnerBitsetHelper()); +} + +void UnionInnerBitsetHelperPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionInnerBitsetHelperPubSubType::getKey( +bool UnionInnerBitsetHelperPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionInnerBitsetHelper data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionInnerBitsetHelperPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5010,35 +4680,27 @@ bool UnionInnerBitsetHelperPubSubType::getKey( const UnionInnerBitsetHelper* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionInnerBitsetHelper_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionInnerBitsetHelper_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5051,49 +4713,42 @@ void UnionInnerBitsetHelperPubSubType::register_type_object_representation() UnionDiscriminatorShortPubSubType::UnionDiscriminatorShortPubSubType() { - setName("UnionDiscriminatorShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorShort::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorShort_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorShort"); + uint32_t type_size = UnionDiscriminatorShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorShort_max_key_cdr_typesize > 16 ? UnionDiscriminatorShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorShort_max_key_cdr_typesize > 16 ? UnionDiscriminatorShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorShortPubSubType::~UnionDiscriminatorShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5108,16 +4763,12 @@ bool UnionDiscriminatorShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5126,18 +4777,14 @@ bool UnionDiscriminatorShortPubSubType::deserialize( UnionDiscriminatorShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5150,52 +4797,62 @@ bool UnionDiscriminatorShortPubSubType::deserialize( return true; } -std::function UnionDiscriminatorShortPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorShortPubSubType::createData() + 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* UnionDiscriminatorShortPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorShort()); } -void UnionDiscriminatorShortPubSubType::deleteData( +void UnionDiscriminatorShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorShortPubSubType::getKey( +bool UnionDiscriminatorShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5203,35 +4860,27 @@ bool UnionDiscriminatorShortPubSubType::getKey( const UnionDiscriminatorShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5244,49 +4893,42 @@ void UnionDiscriminatorShortPubSubType::register_type_object_representation() UnionDiscriminatorUShortPubSubType::UnionDiscriminatorUShortPubSubType() { - setName("UnionDiscriminatorUShort"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorUShort::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorUShort_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorUShort"); + uint32_t type_size = UnionDiscriminatorUShort_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorUShort_max_key_cdr_typesize > 16 ? UnionDiscriminatorUShort_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorUShort_max_key_cdr_typesize > 16 ? UnionDiscriminatorUShort_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorUShortPubSubType::~UnionDiscriminatorUShortPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorUShortPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5301,16 +4943,12 @@ bool UnionDiscriminatorUShortPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorUShortPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5319,18 +4957,14 @@ bool UnionDiscriminatorUShortPubSubType::deserialize( UnionDiscriminatorUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5343,52 +4977,62 @@ bool UnionDiscriminatorUShortPubSubType::deserialize( return true; } -std::function UnionDiscriminatorUShortPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorUShortPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorUShortPubSubType::createData() + 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* UnionDiscriminatorUShortPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorUShort()); } -void UnionDiscriminatorUShortPubSubType::deleteData( +void UnionDiscriminatorUShortPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorUShortPubSubType::getKey( +bool UnionDiscriminatorUShortPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorUShort data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorUShortPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5396,35 +5040,27 @@ bool UnionDiscriminatorUShortPubSubType::getKey( const UnionDiscriminatorUShort* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorUShort_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorUShort_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5437,49 +5073,42 @@ void UnionDiscriminatorUShortPubSubType::register_type_object_representation() UnionDiscriminatorLongPubSubType::UnionDiscriminatorLongPubSubType() { - setName("UnionDiscriminatorLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorLong::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorLong_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorLong"); + uint32_t type_size = UnionDiscriminatorLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorLong_max_key_cdr_typesize > 16 ? UnionDiscriminatorLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorLong_max_key_cdr_typesize > 16 ? UnionDiscriminatorLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorLongPubSubType::~UnionDiscriminatorLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5494,16 +5123,12 @@ bool UnionDiscriminatorLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5512,18 +5137,14 @@ bool UnionDiscriminatorLongPubSubType::deserialize( UnionDiscriminatorLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5536,52 +5157,62 @@ bool UnionDiscriminatorLongPubSubType::deserialize( return true; } -std::function UnionDiscriminatorLongPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorLongPubSubType::createData() + 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* UnionDiscriminatorLongPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorLong()); } -void UnionDiscriminatorLongPubSubType::deleteData( +void UnionDiscriminatorLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorLongPubSubType::getKey( +bool UnionDiscriminatorLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5589,35 +5220,27 @@ bool UnionDiscriminatorLongPubSubType::getKey( const UnionDiscriminatorLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5630,49 +5253,42 @@ void UnionDiscriminatorLongPubSubType::register_type_object_representation() UnionDiscriminatorULongPubSubType::UnionDiscriminatorULongPubSubType() { - setName("UnionDiscriminatorULong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorULong::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorULong_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorULong"); + uint32_t type_size = UnionDiscriminatorULong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorULong_max_key_cdr_typesize > 16 ? UnionDiscriminatorULong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorULong_max_key_cdr_typesize > 16 ? UnionDiscriminatorULong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorULongPubSubType::~UnionDiscriminatorULongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorULongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5687,16 +5303,12 @@ bool UnionDiscriminatorULongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorULongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5705,18 +5317,14 @@ bool UnionDiscriminatorULongPubSubType::deserialize( UnionDiscriminatorULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5729,52 +5337,62 @@ bool UnionDiscriminatorULongPubSubType::deserialize( return true; } -std::function UnionDiscriminatorULongPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorULongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorULongPubSubType::createData() + 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* UnionDiscriminatorULongPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorULong()); } -void UnionDiscriminatorULongPubSubType::deleteData( +void UnionDiscriminatorULongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorULongPubSubType::getKey( +bool UnionDiscriminatorULongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorULong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorULongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5782,35 +5400,27 @@ bool UnionDiscriminatorULongPubSubType::getKey( const UnionDiscriminatorULong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorULong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorULong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -5823,49 +5433,42 @@ void UnionDiscriminatorULongPubSubType::register_type_object_representation() UnionDiscriminatorLongLongPubSubType::UnionDiscriminatorLongLongPubSubType() { - setName("UnionDiscriminatorLongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorLongLong::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorLongLong_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorLongLong"); + uint32_t type_size = UnionDiscriminatorLongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorLongLong_max_key_cdr_typesize > 16 ? UnionDiscriminatorLongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorLongLong_max_key_cdr_typesize > 16 ? UnionDiscriminatorLongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorLongLongPubSubType::~UnionDiscriminatorLongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorLongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -5880,16 +5483,12 @@ bool UnionDiscriminatorLongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorLongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -5898,18 +5497,14 @@ bool UnionDiscriminatorLongLongPubSubType::deserialize( UnionDiscriminatorLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -5922,52 +5517,62 @@ bool UnionDiscriminatorLongLongPubSubType::deserialize( return true; } -std::function UnionDiscriminatorLongLongPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorLongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorLongLongPubSubType::createData() + 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* UnionDiscriminatorLongLongPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorLongLong()); } -void UnionDiscriminatorLongLongPubSubType::deleteData( +void UnionDiscriminatorLongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorLongLongPubSubType::getKey( +bool UnionDiscriminatorLongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorLongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorLongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -5975,35 +5580,27 @@ bool UnionDiscriminatorLongLongPubSubType::getKey( const UnionDiscriminatorLongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorLongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorLongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6016,49 +5613,42 @@ void UnionDiscriminatorLongLongPubSubType::register_type_object_representation() UnionDiscriminatorULongLongPubSubType::UnionDiscriminatorULongLongPubSubType() { - setName("UnionDiscriminatorULongLong"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorULongLong::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorULongLong_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorULongLong"); + uint32_t type_size = UnionDiscriminatorULongLong_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorULongLong_max_key_cdr_typesize > 16 ? UnionDiscriminatorULongLong_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorULongLong_max_key_cdr_typesize > 16 ? UnionDiscriminatorULongLong_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorULongLongPubSubType::~UnionDiscriminatorULongLongPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorULongLongPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6073,16 +5663,12 @@ bool UnionDiscriminatorULongLongPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorULongLongPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6091,18 +5677,14 @@ bool UnionDiscriminatorULongLongPubSubType::deserialize( UnionDiscriminatorULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6115,52 +5697,62 @@ bool UnionDiscriminatorULongLongPubSubType::deserialize( return true; } -std::function UnionDiscriminatorULongLongPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorULongLongPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorULongLongPubSubType::createData() + 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* UnionDiscriminatorULongLongPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorULongLong()); } -void UnionDiscriminatorULongLongPubSubType::deleteData( +void UnionDiscriminatorULongLongPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorULongLongPubSubType::getKey( +bool UnionDiscriminatorULongLongPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorULongLong data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorULongLongPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6168,35 +5760,27 @@ bool UnionDiscriminatorULongLongPubSubType::getKey( const UnionDiscriminatorULongLong* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorULongLong_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorULongLong_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6209,49 +5793,42 @@ void UnionDiscriminatorULongLongPubSubType::register_type_object_representation( UnionDiscriminatorBooleanPubSubType::UnionDiscriminatorBooleanPubSubType() { - setName("UnionDiscriminatorBoolean"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorBoolean::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorBoolean_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorBoolean"); + uint32_t type_size = UnionDiscriminatorBoolean_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorBoolean_max_key_cdr_typesize > 16 ? UnionDiscriminatorBoolean_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorBoolean_max_key_cdr_typesize > 16 ? UnionDiscriminatorBoolean_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorBooleanPubSubType::~UnionDiscriminatorBooleanPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorBooleanPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6266,16 +5843,12 @@ bool UnionDiscriminatorBooleanPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorBooleanPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6284,18 +5857,14 @@ bool UnionDiscriminatorBooleanPubSubType::deserialize( UnionDiscriminatorBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6308,52 +5877,62 @@ bool UnionDiscriminatorBooleanPubSubType::deserialize( return true; } -std::function UnionDiscriminatorBooleanPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorBooleanPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorBooleanPubSubType::createData() + 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* UnionDiscriminatorBooleanPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorBoolean()); } -void UnionDiscriminatorBooleanPubSubType::deleteData( +void UnionDiscriminatorBooleanPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorBooleanPubSubType::getKey( +bool UnionDiscriminatorBooleanPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorBoolean data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorBooleanPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6361,35 +5940,27 @@ bool UnionDiscriminatorBooleanPubSubType::getKey( const UnionDiscriminatorBoolean* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorBoolean_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorBoolean_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6402,49 +5973,42 @@ void UnionDiscriminatorBooleanPubSubType::register_type_object_representation() UnionDiscriminatorOctetPubSubType::UnionDiscriminatorOctetPubSubType() { - setName("UnionDiscriminatorOctet"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorOctet::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorOctet_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorOctet"); + uint32_t type_size = UnionDiscriminatorOctet_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorOctet_max_key_cdr_typesize > 16 ? UnionDiscriminatorOctet_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorOctet_max_key_cdr_typesize > 16 ? UnionDiscriminatorOctet_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorOctetPubSubType::~UnionDiscriminatorOctetPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorOctetPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6459,16 +6023,12 @@ bool UnionDiscriminatorOctetPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorOctetPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6477,18 +6037,14 @@ bool UnionDiscriminatorOctetPubSubType::deserialize( UnionDiscriminatorOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6501,52 +6057,62 @@ bool UnionDiscriminatorOctetPubSubType::deserialize( return true; } -std::function UnionDiscriminatorOctetPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorOctetPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorOctetPubSubType::createData() + 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* UnionDiscriminatorOctetPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorOctet()); } -void UnionDiscriminatorOctetPubSubType::deleteData( +void UnionDiscriminatorOctetPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorOctetPubSubType::getKey( +bool UnionDiscriminatorOctetPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorOctet data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorOctetPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6554,35 +6120,27 @@ bool UnionDiscriminatorOctetPubSubType::getKey( const UnionDiscriminatorOctet* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorOctet_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorOctet_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6595,49 +6153,42 @@ void UnionDiscriminatorOctetPubSubType::register_type_object_representation() UnionDiscriminatorCharPubSubType::UnionDiscriminatorCharPubSubType() { - setName("UnionDiscriminatorChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorChar::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorChar_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorChar"); + uint32_t type_size = UnionDiscriminatorChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorChar_max_key_cdr_typesize > 16 ? UnionDiscriminatorChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorChar_max_key_cdr_typesize > 16 ? UnionDiscriminatorChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorCharPubSubType::~UnionDiscriminatorCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6652,16 +6203,12 @@ bool UnionDiscriminatorCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6670,18 +6217,14 @@ bool UnionDiscriminatorCharPubSubType::deserialize( UnionDiscriminatorChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6694,52 +6237,62 @@ bool UnionDiscriminatorCharPubSubType::deserialize( return true; } -std::function UnionDiscriminatorCharPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorCharPubSubType::createData() + 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* UnionDiscriminatorCharPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorChar()); } -void UnionDiscriminatorCharPubSubType::deleteData( +void UnionDiscriminatorCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorCharPubSubType::getKey( +bool UnionDiscriminatorCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6747,35 +6300,27 @@ bool UnionDiscriminatorCharPubSubType::getKey( const UnionDiscriminatorChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6788,49 +6333,42 @@ void UnionDiscriminatorCharPubSubType::register_type_object_representation() UnionDiscriminatorWCharPubSubType::UnionDiscriminatorWCharPubSubType() { - setName("UnionDiscriminatorWChar"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorWChar::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorWChar_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorWChar"); + uint32_t type_size = UnionDiscriminatorWChar_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorWChar_max_key_cdr_typesize > 16 ? UnionDiscriminatorWChar_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorWChar_max_key_cdr_typesize > 16 ? UnionDiscriminatorWChar_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorWCharPubSubType::~UnionDiscriminatorWCharPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorWCharPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -6845,16 +6383,12 @@ bool UnionDiscriminatorWCharPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorWCharPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -6863,18 +6397,14 @@ bool UnionDiscriminatorWCharPubSubType::deserialize( UnionDiscriminatorWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -6887,52 +6417,62 @@ bool UnionDiscriminatorWCharPubSubType::deserialize( return true; } -std::function UnionDiscriminatorWCharPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorWCharPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorWCharPubSubType::createData() + 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* UnionDiscriminatorWCharPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorWChar()); } -void UnionDiscriminatorWCharPubSubType::deleteData( +void UnionDiscriminatorWCharPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorWCharPubSubType::getKey( +bool UnionDiscriminatorWCharPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorWChar data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorWCharPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -6940,35 +6480,27 @@ bool UnionDiscriminatorWCharPubSubType::getKey( const UnionDiscriminatorWChar* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorWChar_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorWChar_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -6981,49 +6513,42 @@ void UnionDiscriminatorWCharPubSubType::register_type_object_representation() UnionDiscriminatorEnumPubSubType::UnionDiscriminatorEnumPubSubType() { - setName("UnionDiscriminatorEnum"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorEnum::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorEnum_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorEnum"); + uint32_t type_size = UnionDiscriminatorEnum_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorEnum_max_key_cdr_typesize > 16 ? UnionDiscriminatorEnum_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorEnum_max_key_cdr_typesize > 16 ? UnionDiscriminatorEnum_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorEnumPubSubType::~UnionDiscriminatorEnumPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorEnumPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7038,16 +6563,12 @@ bool UnionDiscriminatorEnumPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorEnumPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7056,18 +6577,14 @@ bool UnionDiscriminatorEnumPubSubType::deserialize( UnionDiscriminatorEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7080,52 +6597,62 @@ bool UnionDiscriminatorEnumPubSubType::deserialize( return true; } -std::function UnionDiscriminatorEnumPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorEnumPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorEnumPubSubType::createData() + 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* UnionDiscriminatorEnumPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorEnum()); } -void UnionDiscriminatorEnumPubSubType::deleteData( +void UnionDiscriminatorEnumPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorEnumPubSubType::getKey( +bool UnionDiscriminatorEnumPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorEnum data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorEnumPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7133,35 +6660,27 @@ bool UnionDiscriminatorEnumPubSubType::getKey( const UnionDiscriminatorEnum* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorEnum_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorEnum_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7174,49 +6693,42 @@ void UnionDiscriminatorEnumPubSubType::register_type_object_representation() UnionDiscriminatorEnumLabelPubSubType::UnionDiscriminatorEnumLabelPubSubType() { - setName("UnionDiscriminatorEnumLabel"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorEnumLabel::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorEnumLabel_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorEnumLabel"); + uint32_t type_size = UnionDiscriminatorEnumLabel_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorEnumLabel_max_key_cdr_typesize > 16 ? UnionDiscriminatorEnumLabel_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorEnumLabel_max_key_cdr_typesize > 16 ? UnionDiscriminatorEnumLabel_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorEnumLabelPubSubType::~UnionDiscriminatorEnumLabelPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorEnumLabelPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorEnumLabel* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7231,16 +6743,12 @@ bool UnionDiscriminatorEnumLabelPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorEnumLabelPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7249,18 +6757,14 @@ bool UnionDiscriminatorEnumLabelPubSubType::deserialize( UnionDiscriminatorEnumLabel* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7273,52 +6777,62 @@ bool UnionDiscriminatorEnumLabelPubSubType::deserialize( return true; } -std::function UnionDiscriminatorEnumLabelPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorEnumLabelPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorEnumLabelPubSubType::createData() + 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* UnionDiscriminatorEnumLabelPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorEnumLabel()); } -void UnionDiscriminatorEnumLabelPubSubType::deleteData( +void UnionDiscriminatorEnumLabelPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorEnumLabelPubSubType::getKey( +bool UnionDiscriminatorEnumLabelPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorEnumLabel data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorEnumLabelPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7326,35 +6840,27 @@ bool UnionDiscriminatorEnumLabelPubSubType::getKey( const UnionDiscriminatorEnumLabel* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorEnumLabel_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorEnumLabel_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7367,49 +6873,42 @@ void UnionDiscriminatorEnumLabelPubSubType::register_type_object_representation( UnionDiscriminatorAliasPubSubType::UnionDiscriminatorAliasPubSubType() { - setName("UnionDiscriminatorAlias"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionDiscriminatorAlias::getMaxCdrSerializedSize()); -#else - UnionDiscriminatorAlias_max_cdr_typesize; -#endif + set_name("UnionDiscriminatorAlias"); + uint32_t type_size = UnionDiscriminatorAlias_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionDiscriminatorAlias_max_key_cdr_typesize > 16 ? UnionDiscriminatorAlias_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionDiscriminatorAlias_max_key_cdr_typesize > 16 ? UnionDiscriminatorAlias_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionDiscriminatorAliasPubSubType::~UnionDiscriminatorAliasPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionDiscriminatorAliasPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionDiscriminatorAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7424,16 +6923,12 @@ bool UnionDiscriminatorAliasPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionDiscriminatorAliasPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7442,18 +6937,14 @@ bool UnionDiscriminatorAliasPubSubType::deserialize( UnionDiscriminatorAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7466,52 +6957,62 @@ bool UnionDiscriminatorAliasPubSubType::deserialize( return true; } -std::function UnionDiscriminatorAliasPubSubType::getSerializedSizeProvider( +uint32_t UnionDiscriminatorAliasPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionDiscriminatorAliasPubSubType::createData() + 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* UnionDiscriminatorAliasPubSubType::create_data() { return reinterpret_cast(new UnionDiscriminatorAlias()); } -void UnionDiscriminatorAliasPubSubType::deleteData( +void UnionDiscriminatorAliasPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionDiscriminatorAliasPubSubType::getKey( +bool UnionDiscriminatorAliasPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionDiscriminatorAlias data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionDiscriminatorAliasPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7519,35 +7020,27 @@ bool UnionDiscriminatorAliasPubSubType::getKey( const UnionDiscriminatorAlias* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionDiscriminatorAlias_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionDiscriminatorAlias_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7560,49 +7053,42 @@ void UnionDiscriminatorAliasPubSubType::register_type_object_representation() UnionSeveralFieldsPubSubType::UnionSeveralFieldsPubSubType() { - setName("UnionSeveralFields"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionSeveralFields::getMaxCdrSerializedSize()); -#else - UnionSeveralFields_max_cdr_typesize; -#endif + set_name("UnionSeveralFields"); + uint32_t type_size = UnionSeveralFields_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionSeveralFields_max_key_cdr_typesize > 16 ? UnionSeveralFields_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionSeveralFields_max_key_cdr_typesize > 16 ? UnionSeveralFields_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionSeveralFieldsPubSubType::~UnionSeveralFieldsPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionSeveralFieldsPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionSeveralFields* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7617,16 +7103,12 @@ bool UnionSeveralFieldsPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionSeveralFieldsPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7635,18 +7117,14 @@ bool UnionSeveralFieldsPubSubType::deserialize( UnionSeveralFields* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7659,52 +7137,62 @@ bool UnionSeveralFieldsPubSubType::deserialize( return true; } -std::function UnionSeveralFieldsPubSubType::getSerializedSizeProvider( +uint32_t UnionSeveralFieldsPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionSeveralFieldsPubSubType::createData() + 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* UnionSeveralFieldsPubSubType::create_data() { return reinterpret_cast(new UnionSeveralFields()); } -void UnionSeveralFieldsPubSubType::deleteData( +void UnionSeveralFieldsPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionSeveralFieldsPubSubType::getKey( +bool UnionSeveralFieldsPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionSeveralFields data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionSeveralFieldsPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7712,35 +7200,27 @@ bool UnionSeveralFieldsPubSubType::getKey( const UnionSeveralFields* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionSeveralFields_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionSeveralFields_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -7753,49 +7233,42 @@ void UnionSeveralFieldsPubSubType::register_type_object_representation() UnionSeveralFieldsWithDefaultPubSubType::UnionSeveralFieldsWithDefaultPubSubType() { - setName("UnionSeveralFieldsWithDefault"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionSeveralFieldsWithDefault::getMaxCdrSerializedSize()); -#else - UnionSeveralFieldsWithDefault_max_cdr_typesize; -#endif + set_name("UnionSeveralFieldsWithDefault"); + uint32_t type_size = UnionSeveralFieldsWithDefault_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionSeveralFieldsWithDefault_max_key_cdr_typesize > 16 ? UnionSeveralFieldsWithDefault_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionSeveralFieldsWithDefault_max_key_cdr_typesize > 16 ? UnionSeveralFieldsWithDefault_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionSeveralFieldsWithDefaultPubSubType::~UnionSeveralFieldsWithDefaultPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionSeveralFieldsWithDefaultPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionSeveralFieldsWithDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -7810,16 +7283,12 @@ bool UnionSeveralFieldsWithDefaultPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionSeveralFieldsWithDefaultPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -7828,18 +7297,14 @@ bool UnionSeveralFieldsWithDefaultPubSubType::deserialize( UnionSeveralFieldsWithDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -7852,52 +7317,62 @@ bool UnionSeveralFieldsWithDefaultPubSubType::deserialize( return true; } -std::function UnionSeveralFieldsWithDefaultPubSubType::getSerializedSizeProvider( +uint32_t UnionSeveralFieldsWithDefaultPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* UnionSeveralFieldsWithDefaultPubSubType::createData() + 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* UnionSeveralFieldsWithDefaultPubSubType::create_data() { return reinterpret_cast(new UnionSeveralFieldsWithDefault()); } -void UnionSeveralFieldsWithDefaultPubSubType::deleteData( +void UnionSeveralFieldsWithDefaultPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionSeveralFieldsWithDefaultPubSubType::getKey( +bool UnionSeveralFieldsWithDefaultPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionSeveralFieldsWithDefault data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionSeveralFieldsWithDefaultPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -7905,35 +7380,27 @@ bool UnionSeveralFieldsWithDefaultPubSubType::getKey( const UnionSeveralFieldsWithDefault* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionSeveralFieldsWithDefault_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionSeveralFieldsWithDefault_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/dds-types-test/unionsPubSubTypes.hpp b/test/dds-types-test/unionsPubSubTypes.hpp index 0449462c75d..f4f03cfd3b7 100644 --- a/test/dds-types-test/unionsPubSubTypes.hpp +++ b/test/dds-types-test/unionsPubSubTypes.hpp @@ -33,10 +33,10 @@ #include "helpers/basic_inner_typesPubSubTypes.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated unions is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -55,38 +55,30 @@ class UnionShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -101,10 +93,6 @@ class UnionShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -125,8 +113,10 @@ class UnionShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -146,38 +136,30 @@ class UnionUShortPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -192,10 +174,6 @@ class UnionUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -216,8 +194,10 @@ class UnionUShortPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -237,38 +217,30 @@ class UnionLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -283,10 +255,6 @@ class UnionLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,8 +275,10 @@ class UnionLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -328,38 +298,30 @@ class UnionULongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -374,10 +336,6 @@ class UnionULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -398,8 +356,10 @@ class UnionULongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -419,38 +379,30 @@ class UnionLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -465,10 +417,6 @@ class UnionLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -489,8 +437,10 @@ class UnionLongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -510,38 +460,30 @@ class UnionULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -556,10 +498,6 @@ class UnionULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -580,8 +518,10 @@ class UnionULongLongPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -601,38 +541,30 @@ class UnionFloatPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -647,10 +579,6 @@ class UnionFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -671,8 +599,10 @@ class UnionFloatPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -692,38 +622,30 @@ class UnionDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -738,10 +660,6 @@ class UnionDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -762,8 +680,10 @@ class UnionDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -783,38 +703,30 @@ class UnionLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -829,10 +741,6 @@ class UnionLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -853,8 +761,10 @@ class UnionLongDoublePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -874,38 +784,30 @@ class UnionBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -920,10 +822,6 @@ class UnionBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -944,8 +842,10 @@ class UnionBooleanPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -965,38 +865,30 @@ class UnionOctetPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1011,10 +903,6 @@ class UnionOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1035,8 +923,10 @@ class UnionOctetPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1056,38 +946,30 @@ class UnionCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1102,10 +984,6 @@ class UnionCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1126,8 +1004,10 @@ class UnionCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1147,38 +1027,30 @@ class UnionWCharPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1193,10 +1065,6 @@ class UnionWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1217,8 +1085,10 @@ class UnionWCharPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1238,38 +1108,30 @@ class UnionStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1284,10 +1146,6 @@ class UnionStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1308,8 +1166,10 @@ class UnionStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1329,38 +1189,30 @@ class UnionWStringPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1375,10 +1227,6 @@ class UnionWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1399,8 +1247,10 @@ class UnionWStringPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1420,38 +1270,30 @@ class UnionBoundedStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1466,10 +1308,6 @@ class UnionBoundedStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1490,8 +1328,10 @@ class UnionBoundedStringPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1511,38 +1351,30 @@ class UnionBoundedWStringPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1557,10 +1389,6 @@ class UnionBoundedWStringPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1581,8 +1409,10 @@ class UnionBoundedWStringPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1602,38 +1432,30 @@ class UnionInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1648,10 +1470,6 @@ class UnionInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1672,8 +1490,10 @@ class UnionInnerEnumHelperPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1693,38 +1513,30 @@ class UnionInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1739,10 +1551,6 @@ class UnionInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1763,8 +1571,10 @@ class UnionInnerBitMaskHelperPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1784,38 +1594,30 @@ class UnionInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1830,10 +1632,6 @@ class UnionInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1854,8 +1652,10 @@ class UnionInnerAliasHelperPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1875,38 +1675,30 @@ class UnionArrayPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -1921,10 +1713,6 @@ class UnionArrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -1945,8 +1733,10 @@ class UnionArrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -1966,38 +1756,30 @@ class UnionSequencePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2012,10 +1794,6 @@ class UnionSequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2036,8 +1814,10 @@ class UnionSequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2057,38 +1837,30 @@ class UnionMapPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2103,10 +1875,6 @@ class UnionMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2127,8 +1895,10 @@ class UnionMapPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2148,38 +1918,30 @@ class UnionInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2194,10 +1956,6 @@ class UnionInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2218,8 +1976,10 @@ class UnionInnerUnionHelperPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2239,38 +1999,30 @@ class UnionInnerStructureHelperPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2285,10 +2037,6 @@ class UnionInnerStructureHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2309,8 +2057,10 @@ class UnionInnerStructureHelperPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2330,38 +2080,30 @@ class UnionInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2376,10 +2118,6 @@ class UnionInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2400,8 +2138,10 @@ class UnionInnerBitsetHelperPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2421,38 +2161,30 @@ class UnionDiscriminatorShortPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2467,10 +2199,6 @@ class UnionDiscriminatorShortPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2491,8 +2219,10 @@ class UnionDiscriminatorShortPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2512,38 +2242,30 @@ class UnionDiscriminatorUShortPubSubType : public eprosima::fastdds::dds::TopicD eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2558,10 +2280,6 @@ class UnionDiscriminatorUShortPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2582,8 +2300,10 @@ class UnionDiscriminatorUShortPubSubType : public eprosima::fastdds::dds::TopicD #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2603,38 +2323,30 @@ class UnionDiscriminatorLongPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2649,10 +2361,6 @@ class UnionDiscriminatorLongPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2673,8 +2381,10 @@ class UnionDiscriminatorLongPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2694,38 +2404,30 @@ class UnionDiscriminatorULongPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2740,10 +2442,6 @@ class UnionDiscriminatorULongPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2764,8 +2462,10 @@ class UnionDiscriminatorULongPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2785,38 +2485,30 @@ class UnionDiscriminatorLongLongPubSubType : public eprosima::fastdds::dds::Topi eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2831,10 +2523,6 @@ class UnionDiscriminatorLongLongPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2855,8 +2543,10 @@ class UnionDiscriminatorLongLongPubSubType : public eprosima::fastdds::dds::Topi #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2876,38 +2566,30 @@ class UnionDiscriminatorULongLongPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -2922,10 +2604,6 @@ class UnionDiscriminatorULongLongPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -2946,8 +2624,10 @@ class UnionDiscriminatorULongLongPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -2967,38 +2647,30 @@ class UnionDiscriminatorBooleanPubSubType : public eprosima::fastdds::dds::Topic eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3013,10 +2685,6 @@ class UnionDiscriminatorBooleanPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3037,8 +2705,10 @@ class UnionDiscriminatorBooleanPubSubType : public eprosima::fastdds::dds::Topic #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3058,38 +2728,30 @@ class UnionDiscriminatorOctetPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3104,10 +2766,6 @@ class UnionDiscriminatorOctetPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3128,8 +2786,10 @@ class UnionDiscriminatorOctetPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3149,38 +2809,30 @@ class UnionDiscriminatorCharPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3195,10 +2847,6 @@ class UnionDiscriminatorCharPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3219,8 +2867,10 @@ class UnionDiscriminatorCharPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3240,38 +2890,30 @@ class UnionDiscriminatorWCharPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3286,10 +2928,6 @@ class UnionDiscriminatorWCharPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3310,8 +2948,10 @@ class UnionDiscriminatorWCharPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3331,38 +2971,30 @@ class UnionDiscriminatorEnumPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3377,10 +3009,6 @@ class UnionDiscriminatorEnumPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3401,8 +3029,10 @@ class UnionDiscriminatorEnumPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3422,38 +3052,30 @@ class UnionDiscriminatorEnumLabelPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3468,10 +3090,6 @@ class UnionDiscriminatorEnumLabelPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3492,8 +3110,10 @@ class UnionDiscriminatorEnumLabelPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3513,38 +3133,30 @@ class UnionDiscriminatorAliasPubSubType : public eprosima::fastdds::dds::TopicDa eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3559,10 +3171,6 @@ class UnionDiscriminatorAliasPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3583,8 +3191,10 @@ class UnionDiscriminatorAliasPubSubType : public eprosima::fastdds::dds::TopicDa #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3604,38 +3214,30 @@ class UnionSeveralFieldsPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3650,10 +3252,6 @@ class UnionSeveralFieldsPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3674,8 +3272,10 @@ class UnionSeveralFieldsPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -3695,38 +3295,30 @@ class UnionSeveralFieldsWithDefaultPubSubType : public eprosima::fastdds::dds::T eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -3741,10 +3333,6 @@ class UnionSeveralFieldsWithDefaultPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -3765,8 +3353,10 @@ class UnionSeveralFieldsWithDefaultPubSubType : public eprosima::fastdds::dds::T #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/feature/dynamic_types/DynamicTypesDDSTypesTest.cpp b/test/feature/dynamic_types/DynamicTypesDDSTypesTest.cpp index 2d2a4cb8506..e668790bb6d 100644 --- a/test/feature/dynamic_types/DynamicTypesDDSTypesTest.cpp +++ b/test/feature/dynamic_types/DynamicTypesDDSTypesTest.cpp @@ -238,7 +238,7 @@ DynamicType::_ref_type DynamicTypesDDSTypesTest::create_inner_bitset_helper() MemberDescriptor::_ref_type bitset_member {traits::make_shared()}; bitset_member->name(bitfield_a); - bitset_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BYTE)); + bitset_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT8)); bitset_member->id(0); bitset_builder->add_member(bitset_member); bitset_member = traits::make_shared(); diff --git a/test/feature/dynamic_types/DynamicTypesDDSTypesTest.hpp b/test/feature/dynamic_types/DynamicTypesDDSTypesTest.hpp index 11f24002514..619012777c2 100644 --- a/test/feature/dynamic_types/DynamicTypesDDSTypesTest.hpp +++ b/test/feature/dynamic_types/DynamicTypesDDSTypesTest.hpp @@ -111,28 +111,28 @@ class DynamicTypesDDSTypesTest : public ::testing::Test { TypeSupport dyn_pubsubType {new DynamicPubSubType(type)}; - uint32_t dyn_payloadSize = static_cast(dyn_pubsubType.get_serialized_size_provider(&data, - data_representation)()); + uint32_t dyn_payloadSize = static_cast(dyn_pubsubType.calculate_serialized_size(&data, + data_representation)); // Dynamic Serialization <-> Dynamic Deserialization eprosima::fastdds::rtps::SerializedPayload_t dyn_payload(dyn_payloadSize); - ASSERT_TRUE(dyn_pubsubType.serialize(&data, &dyn_payload, data_representation)); + ASSERT_TRUE(dyn_pubsubType.serialize(&data, dyn_payload, data_representation)); DynamicData::_ref_type data1 {DynamicDataFactory::get_instance()->create_data(type)}; - ASSERT_TRUE(dyn_pubsubType.deserialize(&dyn_payload, &data1)); + ASSERT_TRUE(dyn_pubsubType.deserialize(dyn_payload, &data1)); EXPECT_TRUE(data1->equals(data)); // Dynamic Serialization <-> Static Deserialization - ASSERT_TRUE(static_pubsubType.deserialize(&dyn_payload, &data_static)); + ASSERT_TRUE(static_pubsubType.deserialize(dyn_payload, &data_static)); // Static Serialization <-> Dynamic Deserialization - uint32_t static_payloadSize = static_cast(static_pubsubType.get_serialized_size_provider(&data_static, - data_representation)()); + uint32_t static_payloadSize = static_pubsubType.calculate_serialized_size(&data_static, + data_representation); EXPECT_EQ(static_payloadSize, dyn_payloadSize); eprosima::fastdds::rtps::SerializedPayload_t static_payload(static_payloadSize); - ASSERT_TRUE(static_pubsubType.serialize(&data_static, &static_payload, data_representation)); + ASSERT_TRUE(static_pubsubType.serialize(&data_static, static_payload, data_representation)); EXPECT_EQ(static_payload.length, static_payloadSize); DynamicData::_ref_type data2 {DynamicDataFactory::get_instance()->create_data(type)}; - ASSERT_TRUE(dyn_pubsubType.deserialize(&static_payload, &data2)); + ASSERT_TRUE(dyn_pubsubType.deserialize(static_payload, &data2)); EXPECT_TRUE(data2->equals(data)); EXPECT_EQ(DynamicDataFactory::get_instance()->delete_data(data1), RETCODE_OK); diff --git a/test/feature/dynamic_types/DynamicTypesTests.cpp b/test/feature/dynamic_types/DynamicTypesTests.cpp index f758dd0cec4..95400ac3c0a 100644 --- a/test/feature/dynamic_types/DynamicTypesTests.cpp +++ b/test/feature/dynamic_types/DynamicTypesTests.cpp @@ -45,12 +45,12 @@ void encoding_decoding_test( { TypeSupport pubsubType {new DynamicPubSubType(created_type)}; uint32_t payloadSize = - static_cast(pubsubType.get_serialized_size_provider(&encoding_data, encoding)()); + static_cast(pubsubType.calculate_serialized_size(&encoding_data, encoding)); SerializedPayload_t payload(payloadSize); - EXPECT_TRUE(pubsubType.serialize(&encoding_data, &payload, encoding)); + EXPECT_TRUE(pubsubType.serialize(&encoding_data, payload, encoding)); EXPECT_EQ(payload.length, payloadSize); - EXPECT_LE(payload.length, pubsubType->m_typeSize); - EXPECT_TRUE(pubsubType.deserialize(&payload, &decoding_data)); + EXPECT_LE(payload.length, pubsubType->max_serialized_type_size); + EXPECT_TRUE(pubsubType.deserialize(payload, &decoding_data)); EXPECT_TRUE(decoding_data->equals(encoding_data)); DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( @@ -12733,7 +12733,7 @@ TEST_F(DynamicTypesTests, DynamicType_KeyHash_standard_example_1) TypeSupport pubsubType {new DynamicPubSubType(struct_type)}; eprosima::fastdds::rtps::InstanceHandle_t instance_handle; - ASSERT_TRUE(pubsubType.get_key(&data, &instance_handle)); + ASSERT_TRUE(pubsubType.compute_key(&data, instance_handle)); const uint8_t expected_key_hash[] { 0x12, 0x34, 0x56, 0x78, @@ -12803,7 +12803,7 @@ TEST_F(DynamicTypesTests, DynamicType_KeyHash_standard_example_2) TypeSupport pubsubType {new DynamicPubSubType(struct_type)}; eprosima::fastdds::rtps::InstanceHandle_t instance_handle; - ASSERT_TRUE(pubsubType.get_key(&data, &instance_handle)); + ASSERT_TRUE(pubsubType.compute_key(&data, instance_handle)); const uint8_t expected_key_hash[] { 0xf9, 0x1a, 0x59, 0xe3, @@ -12910,7 +12910,7 @@ TEST_F(DynamicTypesTests, DynamicType_KeyHash_standard_example_3) TypeSupport pubsubType {new DynamicPubSubType(struct_type)}; eprosima::fastdds::rtps::InstanceHandle_t instance_handle; - ASSERT_TRUE(pubsubType.get_key(&data, &instance_handle)); + ASSERT_TRUE(pubsubType.compute_key(&data, instance_handle)); const uint8_t expected_key_hash[] { 0x37, 0x4b, 0x96, 0xe2, diff --git a/test/feature/dynamic_types/dds_types_tests/DynamicTypesAliasesDDSTypesTests.cpp b/test/feature/dynamic_types/dds_types_tests/DynamicTypesAliasesDDSTypesTests.cpp index f01558a524c..3e62e76a58c 100644 --- a/test/feature/dynamic_types/dds_types_tests/DynamicTypesAliasesDDSTypesTests.cpp +++ b/test/feature/dynamic_types/dds_types_tests/DynamicTypesAliasesDDSTypesTests.cpp @@ -1234,8 +1234,8 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_AliasBitset) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - eprosima::fastdds::rtps::octet octet_value = 5; - eprosima::fastdds::rtps::octet test_octet_value = 0; + uint8_t uint8_value = 5; + uint8_t test_uint8_value = 0; bool bool_value = true; bool test_bool_value = false; uint16_t ushort_value = 1000; @@ -1244,10 +1244,10 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_AliasBitset) int16_t test_short_value = 0; DynamicData::_ref_type bitset_data = data->loan_value(data->get_member_id_by_name(struct_member_name)); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), octet_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), uint8_value), RETCODE_OK); + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(octet_value, test_octet_value); + EXPECT_EQ(uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name(bitfield_b), bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( bitfield_b)), RETCODE_OK); @@ -1267,7 +1267,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_AliasBitset) AliasBitset alias_data; TypeSupport static_pubsubType {new AliasBitsetPubSubType()}; check_serialization_deserialization(struct_type, data, encoding, alias_data, static_pubsubType); - EXPECT_EQ(alias_data.value().a, test_octet_value); + EXPECT_EQ(alias_data.value().a, test_uint8_value); EXPECT_EQ(alias_data.value().b, test_bool_value); EXPECT_EQ(alias_data.value().c, test_ushort_value); EXPECT_EQ(alias_data.value().d, test_short_value); diff --git a/test/feature/dynamic_types/dds_types_tests/DynamicTypesArraysDDSTypesTests.cpp b/test/feature/dynamic_types/dds_types_tests/DynamicTypesArraysDDSTypesTests.cpp index 222385c95f2..9d525ef929b 100644 --- a/test/feature/dynamic_types/dds_types_tests/DynamicTypesArraysDDSTypesTests.cpp +++ b/test/feature/dynamic_types/dds_types_tests/DynamicTypesArraysDDSTypesTests.cpp @@ -1403,9 +1403,9 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayBitset) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - eprosima::fastdds::rtps::octet first_octet_value = 5; - eprosima::fastdds::rtps::octet second_octet_value = 7; - eprosima::fastdds::rtps::octet test_octet_value = 0; + uint8_t first_uint8_value = 5; + uint8_t second_uint8_value = 7; + uint8_t test_uint8_value = 0; bool first_bool_value = true; bool second_bool_value = false; bool test_bool_value = false; @@ -1419,11 +1419,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayBitset) ASSERT_TRUE(array_data); DynamicData::_ref_type bitset_data = array_data->loan_value(0); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), first_octet_value), + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), first_uint8_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(first_octet_value, test_octet_value); + EXPECT_EQ(first_uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name( bitfield_b), first_bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( @@ -1442,11 +1442,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayBitset) EXPECT_EQ(array_data->return_loaned_value(bitset_data), RETCODE_OK); bitset_data = array_data->loan_value(1); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name( - bitfield_a), second_octet_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name( + bitfield_a), second_uint8_value), RETCODE_OK); + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(second_octet_value, test_octet_value); + EXPECT_EQ(second_uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name( bitfield_b), second_bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( @@ -1468,7 +1468,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayBitset) { bitset_data = array_data->loan_value(i); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name( + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name( bitfield_a)), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( bitfield_b)), RETCODE_OK); @@ -1476,7 +1476,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayBitset) bitfield_c)), RETCODE_OK); EXPECT_EQ(bitset_data->get_int16_value(test_short_value, bitset_data->get_member_id_by_name( bitfield_d)), RETCODE_OK); - EXPECT_EQ(test_octet_value, 0u); + EXPECT_EQ(test_uint8_value, 0u); EXPECT_EQ(test_bool_value, false); EXPECT_EQ(test_ushort_value, 0u); EXPECT_EQ(test_short_value, 0); @@ -1488,11 +1488,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayBitset) ArrayBitset struct_data; TypeSupport static_pubsubType {new ArrayBitsetPubSubType()}; check_serialization_deserialization(struct_type, data, encoding, struct_data, static_pubsubType); - EXPECT_EQ(struct_data.var_array_bitset()[0].a, first_octet_value); + EXPECT_EQ(struct_data.var_array_bitset()[0].a, first_uint8_value); EXPECT_EQ(struct_data.var_array_bitset()[0].b, first_bool_value); EXPECT_EQ(struct_data.var_array_bitset()[0].c, first_ushort_value); EXPECT_EQ(struct_data.var_array_bitset()[0].d, first_short_value); - EXPECT_EQ(struct_data.var_array_bitset()[1].a, second_octet_value); + EXPECT_EQ(struct_data.var_array_bitset()[1].a, second_uint8_value); EXPECT_EQ(struct_data.var_array_bitset()[1].b, second_bool_value); EXPECT_EQ(struct_data.var_array_bitset()[1].c, second_ushort_value); EXPECT_EQ(struct_data.var_array_bitset()[1].d, second_short_value); @@ -3200,10 +3200,10 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayMultiDimensionBitset) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - eprosima::fastdds::rtps::octet first_octet_value = 5; - eprosima::fastdds::rtps::octet second_octet_value = 7; - eprosima::fastdds::rtps::octet third_octet_value = 1; - eprosima::fastdds::rtps::octet test_octet_value = 0; + uint8_t first_uint8_value = 5; + uint8_t second_uint8_value = 7; + uint8_t third_uint8_value = 1; + uint8_t test_uint8_value = 0; bool first_bool_value = true; bool second_bool_value = false; bool third_bool_value = true; @@ -3220,11 +3220,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayMultiDimensionBitset) ASSERT_TRUE(array_data); DynamicData::_ref_type bitset_data = array_data->loan_value(0); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), first_octet_value), + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), first_uint8_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(first_octet_value, test_octet_value); + EXPECT_EQ(first_uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name( bitfield_b), first_bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( @@ -3243,11 +3243,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayMultiDimensionBitset) EXPECT_EQ(array_data->return_loaned_value(bitset_data), RETCODE_OK); bitset_data = array_data->loan_value(33); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name( - bitfield_a), second_octet_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name( + bitfield_a), second_uint8_value), RETCODE_OK); + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(second_octet_value, test_octet_value); + EXPECT_EQ(second_uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name( bitfield_b), second_bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( @@ -3266,11 +3266,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayMultiDimensionBitset) EXPECT_EQ(array_data->return_loaned_value(bitset_data), RETCODE_OK); bitset_data = array_data->loan_value(857); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), third_octet_value), + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), third_uint8_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(third_octet_value, test_octet_value); + EXPECT_EQ(third_uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name( bitfield_b), third_bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( @@ -3302,21 +3302,21 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_ArrayMultiDimensionBitset) { if (i == 0 && j == 0 && k == 0) { - EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].a, first_octet_value); + EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].a, first_uint8_value); EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].b, first_bool_value); EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].c, first_ushort_value); EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].d, first_short_value); } else if (i == 0 && j == 3 && k == 3) { - EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].a, second_octet_value); + EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].a, second_uint8_value); EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].b, second_bool_value); EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].c, second_ushort_value); EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].d, second_short_value); } else if (i == 8 && j == 5 && k == 7) { - EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].a, third_octet_value); + EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].a, third_uint8_value); EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].b, third_bool_value); EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].c, third_ushort_value); EXPECT_EQ(struct_data.var_array_bitset()[i][j][k].d, third_short_value); diff --git a/test/feature/dynamic_types/dds_types_tests/DynamicTypesBitsetsDDSTypesTests.cpp b/test/feature/dynamic_types/dds_types_tests/DynamicTypesBitsetsDDSTypesTests.cpp index 5733edd180f..3a32d2064d5 100644 --- a/test/feature/dynamic_types/dds_types_tests/DynamicTypesBitsetsDDSTypesTests.cpp +++ b/test/feature/dynamic_types/dds_types_tests/DynamicTypesBitsetsDDSTypesTests.cpp @@ -214,11 +214,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_BitsetStruct) DynamicData::_ref_type var_innerbitsethelper_data = data->loan_value(data->get_member_id_by_name(var_innerbitsethelper_name)); ASSERT_TRUE(var_innerbitsethelper_data); - EXPECT_EQ(var_innerbitsethelper_data->set_byte_value( - var_innerbitsethelper_data->get_member_id_by_name(bitfield_a), octet_value), RETCODE_OK); - EXPECT_EQ(var_innerbitsethelper_data->get_byte_value( - test_octet_value, var_innerbitsethelper_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(octet_value, test_octet_value); + EXPECT_EQ(var_innerbitsethelper_data->set_uint8_value( + var_innerbitsethelper_data->get_member_id_by_name(bitfield_a), uint8_value), RETCODE_OK); + EXPECT_EQ(var_innerbitsethelper_data->get_uint8_value( + test_uint8_value, var_innerbitsethelper_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); + EXPECT_EQ(uint8_value, uint8_value); EXPECT_EQ(var_innerbitsethelper_data->set_boolean_value( var_innerbitsethelper_data->get_member_id_by_name(bitfield_b), bool_value), RETCODE_OK); EXPECT_EQ(var_innerbitsethelper_data->get_boolean_value( diff --git a/test/feature/dynamic_types/dds_types_tests/DynamicTypesInheritanceDDSTypesTests.cpp b/test/feature/dynamic_types/dds_types_tests/DynamicTypesInheritanceDDSTypesTests.cpp index 57c2dd04037..9ad4044c3a1 100644 --- a/test/feature/dynamic_types/dds_types_tests/DynamicTypesInheritanceDDSTypesTests.cpp +++ b/test/feature/dynamic_types/dds_types_tests/DynamicTypesInheritanceDDSTypesTests.cpp @@ -861,12 +861,12 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_BitsetsChildInheritanceStruct) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - eprosima::fastdds::rtps::octet octet_value {5}; + uint8_t uint8_value {5}; bool bool_value {true}; uint16_t ushort_value {1000}; int16_t short_value {2000}; uint32_t long_value {111}; - eprosima::fastdds::rtps::octet test_octet_value; + uint8_t test_uint8_value; bool test_bool_value; uint16_t test_ushort_value; int16_t test_short_value; @@ -875,14 +875,14 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_BitsetsChildInheritanceStruct) // Set values. DynamicData::_ref_type bitset_data {data->loan_value(data->get_member_id_by_name(var_InnerBitsetHelperChild))}; ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), octet_value), RETCODE_OK); + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), uint8_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name(bitfield_b), bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_uint16_value(bitset_data->get_member_id_by_name(bitfield_c), ushort_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_int16_value(bitset_data->get_member_id_by_name(bitfield_d), short_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_uint32_value(bitset_data->get_member_id_by_name(child_w), long_value), RETCODE_OK); EXPECT_EQ(data->return_loaned_value(bitset_data), RETCODE_OK); bitset_data = data->loan_value(data->get_member_id_by_name(var_InnerBitsetHelperChildChild)); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), octet_value), RETCODE_OK); + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), uint8_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name(bitfield_b), bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_uint16_value(bitset_data->get_member_id_by_name(bitfield_c), ushort_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_int16_value(bitset_data->get_member_id_by_name(bitfield_d), short_value), RETCODE_OK); @@ -891,7 +891,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_BitsetsChildInheritanceStruct) RETCODE_OK); EXPECT_EQ(data->return_loaned_value(bitset_data), RETCODE_OK); bitset_data = data->loan_value(data->get_member_id_by_name(var_BitsetAliasInheritanceBitset)); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), octet_value), RETCODE_OK); + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), uint8_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name(bitfield_b), bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_uint16_value(bitset_data->get_member_id_by_name(bitfield_c), ushort_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_int16_value(bitset_data->get_member_id_by_name(bitfield_d), short_value), RETCODE_OK); @@ -902,9 +902,9 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_BitsetsChildInheritanceStruct) // Check values bitset_data = data->loan_value(data->get_member_id_by_name(var_InnerBitsetHelperChild)); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(octet_value, test_octet_value); + EXPECT_EQ(uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( bitfield_b)), RETCODE_OK); EXPECT_EQ(bool_value, test_bool_value); @@ -920,9 +920,9 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_BitsetsChildInheritanceStruct) EXPECT_EQ(data->return_loaned_value(bitset_data), RETCODE_OK); bitset_data = data->loan_value(data->get_member_id_by_name(var_InnerBitsetHelperChildChild)); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(octet_value, test_octet_value); + EXPECT_EQ(uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( bitfield_b)), RETCODE_OK); EXPECT_EQ(bool_value, test_bool_value); @@ -941,9 +941,9 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_BitsetsChildInheritanceStruct) EXPECT_EQ(data->return_loaned_value(bitset_data), RETCODE_OK); bitset_data = data->loan_value(data->get_member_id_by_name(var_BitsetAliasInheritanceBitset)); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(octet_value, test_octet_value); + EXPECT_EQ(uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( bitfield_b)), RETCODE_OK); EXPECT_EQ(bool_value, test_bool_value); @@ -964,18 +964,18 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_BitsetsChildInheritanceStruct) TypeSupport static_pubsubType {new BitsetsChildInheritanceStructPubSubType()}; check_serialization_deserialization(struct_type, data, encoding, struct_data, static_pubsubType); - EXPECT_EQ(octet_value, struct_data.var_InnerBitsetHelperChild().a); + EXPECT_EQ(uint8_value, struct_data.var_InnerBitsetHelperChild().a); EXPECT_EQ(bool_value, struct_data.var_InnerBitsetHelperChild().b); EXPECT_EQ(ushort_value, struct_data.var_InnerBitsetHelperChild().c); EXPECT_EQ(short_value, struct_data.var_InnerBitsetHelperChild().d); EXPECT_EQ(long_value, struct_data.var_InnerBitsetHelperChild().child_w); - EXPECT_EQ(octet_value, struct_data.var_InnerBitsetHelperChildChild().a); + EXPECT_EQ(uint8_value, struct_data.var_InnerBitsetHelperChildChild().a); EXPECT_EQ(bool_value, struct_data.var_InnerBitsetHelperChildChild().b); EXPECT_EQ(ushort_value, struct_data.var_InnerBitsetHelperChildChild().c); EXPECT_EQ(short_value, struct_data.var_InnerBitsetHelperChildChild().d); EXPECT_EQ(long_value, struct_data.var_InnerBitsetHelperChildChild().child_w); EXPECT_EQ(ushort_value, struct_data.var_InnerBitsetHelperChildChild().childchild_z); - EXPECT_EQ(octet_value, struct_data.var_BitsetAliasInheritanceBitset().a); + EXPECT_EQ(uint8_value, struct_data.var_BitsetAliasInheritanceBitset().a); EXPECT_EQ(bool_value, struct_data.var_BitsetAliasInheritanceBitset().b); EXPECT_EQ(ushort_value, struct_data.var_BitsetAliasInheritanceBitset().c); EXPECT_EQ(short_value, struct_data.var_BitsetAliasInheritanceBitset().d); diff --git a/test/feature/dynamic_types/dds_types_tests/DynamicTypesMapsDDSTypesTests.cpp b/test/feature/dynamic_types/dds_types_tests/DynamicTypesMapsDDSTypesTests.cpp index 1e9adaeb60b..6c9f298ce13 100644 --- a/test/feature/dynamic_types/dds_types_tests/DynamicTypesMapsDDSTypesTests.cpp +++ b/test/feature/dynamic_types/dds_types_tests/DynamicTypesMapsDDSTypesTests.cpp @@ -2349,12 +2349,12 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapShortInnerBitsetHelper) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - const std::unordered_map> value { - {std::int16_t(-100), {eprosima::fastdds::rtps::octet(5), true, std::uint16_t(1000), std::int16_t(2000)}}, - {std::int16_t(50), {eprosima::fastdds::rtps::octet(7), false, std::uint16_t(555), std::int16_t(20)}}, - {std::int16_t(600), {eprosima::fastdds::rtps::octet(0), true, std::uint16_t(0), std::int16_t(0)}} + const std::unordered_map> value { + {std::int16_t(-100), {std::uint8_t(5), true, std::uint16_t(1000), std::int16_t(2000)}}, + {std::int16_t(50), {std::uint8_t(7), false, std::uint16_t(555), std::int16_t(20)}}, + {std::int16_t(600), {std::uint8_t(0), true, std::uint16_t(0), std::int16_t(0)}} }; - eprosima::fastdds::rtps::octet test_value1; + uint8_t test_value1; bool test_value2; uint16_t test_value3; int16_t test_value4; @@ -2366,7 +2366,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapShortInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->set_byte_value(inner_bitset->get_member_id_by_name(bitfield_a), + inner_bitset->set_uint8_value(inner_bitset->get_member_id_by_name(bitfield_a), std::get<0>(map_element.second))); EXPECT_EQ(RETCODE_OK, inner_bitset->set_boolean_value(inner_bitset->get_member_id_by_name(bitfield_b), @@ -2386,7 +2386,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapShortInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->get_byte_value(test_value1, + inner_bitset->get_uint8_value(test_value1, inner_bitset->get_member_id_by_name(bitfield_a))); EXPECT_EQ(std::get<0>(map_element.second), test_value1); EXPECT_EQ(RETCODE_OK, @@ -4244,12 +4244,12 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapUShortInnerBitsetHelper) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - const std::unordered_map> value { - {std::uint16_t(100), {eprosima::fastdds::rtps::octet(5), true, std::uint16_t(1000), std::int16_t(2000)}}, - {std::uint16_t(50), {eprosima::fastdds::rtps::octet(7), false, std::uint16_t(555), std::int16_t(20)}}, - {std::uint16_t(600), {eprosima::fastdds::rtps::octet(0), true, std::uint16_t(0), std::int16_t(0)}} + const std::unordered_map> value { + {std::uint16_t(100), {std::uint8_t(5), true, std::uint16_t(1000), std::int16_t(2000)}}, + {std::uint16_t(50), {std::uint8_t(7), false, std::uint16_t(555), std::int16_t(20)}}, + {std::uint16_t(600), {std::uint8_t(0), true, std::uint16_t(0), std::int16_t(0)}} }; - eprosima::fastdds::rtps::octet test_value1; + uint8_t test_value1; bool test_value2; uint16_t test_value3; int16_t test_value4; @@ -4261,7 +4261,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapUShortInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->set_byte_value(inner_bitset->get_member_id_by_name(bitfield_a), + inner_bitset->set_uint8_value(inner_bitset->get_member_id_by_name(bitfield_a), std::get<0>(map_element.second))); EXPECT_EQ(RETCODE_OK, inner_bitset->set_boolean_value(inner_bitset->get_member_id_by_name(bitfield_b), @@ -4281,7 +4281,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapUShortInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->get_byte_value(test_value1, + inner_bitset->get_uint8_value(test_value1, inner_bitset->get_member_id_by_name(bitfield_a))); EXPECT_EQ(std::get<0>(map_element.second), test_value1); EXPECT_EQ(RETCODE_OK, @@ -6138,12 +6138,12 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapLongInnerBitsetHelper) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - const std::unordered_map> value { - {-100, {eprosima::fastdds::rtps::octet(5), true, std::uint16_t(1000), std::int16_t(2000)}}, - {50, {eprosima::fastdds::rtps::octet(7), false, std::uint16_t(555), std::int16_t(20)}}, - {600, {eprosima::fastdds::rtps::octet(0), true, std::uint16_t(0), std::int16_t(0)}} + const std::unordered_map> value { + {-100, {std::uint8_t(5), true, std::uint16_t(1000), std::int16_t(2000)}}, + {50, {std::uint8_t(7), false, std::uint16_t(555), std::int16_t(20)}}, + {600, {std::uint8_t(0), true, std::uint16_t(0), std::int16_t(0)}} }; - eprosima::fastdds::rtps::octet test_value1; + uint8_t test_value1; bool test_value2; uint16_t test_value3; int16_t test_value4; @@ -6155,7 +6155,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapLongInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->set_byte_value(inner_bitset->get_member_id_by_name(bitfield_a), + inner_bitset->set_uint8_value(inner_bitset->get_member_id_by_name(bitfield_a), std::get<0>(map_element.second))); EXPECT_EQ(RETCODE_OK, inner_bitset->set_boolean_value(inner_bitset->get_member_id_by_name(bitfield_b), @@ -6175,7 +6175,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapLongInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->get_byte_value(test_value1, + inner_bitset->get_uint8_value(test_value1, inner_bitset->get_member_id_by_name(bitfield_a))); EXPECT_EQ(std::get<0>(map_element.second), test_value1); EXPECT_EQ(RETCODE_OK, @@ -8032,12 +8032,12 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapULongInnerBitsetHelper) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - const std::unordered_map> value { - {100u, {eprosima::fastdds::rtps::octet(5), true, std::uint16_t(1000), std::int16_t(2000)}}, - {50u, {eprosima::fastdds::rtps::octet(7), false, std::uint16_t(555), std::int16_t(20)}}, - {600u, {eprosima::fastdds::rtps::octet(0), true, std::uint16_t(0), std::int16_t(0)}} + const std::unordered_map> value { + {100u, {std::uint8_t(5), true, std::uint16_t(1000), std::int16_t(2000)}}, + {50u, {std::uint8_t(7), false, std::uint16_t(555), std::int16_t(20)}}, + {600u, {std::uint8_t(0), true, std::uint16_t(0), std::int16_t(0)}} }; - eprosima::fastdds::rtps::octet test_value1; + uint8_t test_value1; bool test_value2; uint16_t test_value3; int16_t test_value4; @@ -8049,7 +8049,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapULongInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->set_byte_value(inner_bitset->get_member_id_by_name(bitfield_a), + inner_bitset->set_uint8_value(inner_bitset->get_member_id_by_name(bitfield_a), std::get<0>(map_element.second))); EXPECT_EQ(RETCODE_OK, inner_bitset->set_boolean_value(inner_bitset->get_member_id_by_name(bitfield_b), @@ -8069,7 +8069,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapULongInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->get_byte_value(test_value1, + inner_bitset->get_uint8_value(test_value1, inner_bitset->get_member_id_by_name(bitfield_a))); EXPECT_EQ(std::get<0>(map_element.second), test_value1); EXPECT_EQ(RETCODE_OK, @@ -9926,12 +9926,12 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapLongLongInnerBitsetHelper) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - const std::unordered_map> value { - {-100, {eprosima::fastdds::rtps::octet(5), true, std::uint16_t(1000), std::int16_t(2000)}}, - {50, {eprosima::fastdds::rtps::octet(7), false, std::uint16_t(555), std::int16_t(20)}}, - {600, {eprosima::fastdds::rtps::octet(0), true, std::uint16_t(0), std::int16_t(0)}} + const std::unordered_map> value { + {-100, {std::uint8_t(5), true, std::uint16_t(1000), std::int16_t(2000)}}, + {50, {std::uint8_t(7), false, std::uint16_t(555), std::int16_t(20)}}, + {600, {std::uint8_t(0), true, std::uint16_t(0), std::int16_t(0)}} }; - eprosima::fastdds::rtps::octet test_value1; + uint8_t test_value1; bool test_value2; uint16_t test_value3; int16_t test_value4; @@ -9943,7 +9943,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapLongLongInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->set_byte_value(inner_bitset->get_member_id_by_name(bitfield_a), + inner_bitset->set_uint8_value(inner_bitset->get_member_id_by_name(bitfield_a), std::get<0>(map_element.second))); EXPECT_EQ(RETCODE_OK, inner_bitset->set_boolean_value(inner_bitset->get_member_id_by_name(bitfield_b), @@ -9963,7 +9963,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapLongLongInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->get_byte_value(test_value1, + inner_bitset->get_uint8_value(test_value1, inner_bitset->get_member_id_by_name(bitfield_a))); EXPECT_EQ(std::get<0>(map_element.second), test_value1); EXPECT_EQ(RETCODE_OK, @@ -11820,12 +11820,12 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapULongLongInnerBitsetHelper) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - const std::unordered_map> value { - {100u, {eprosima::fastdds::rtps::octet(5), true, std::uint16_t(1000), std::int16_t(2000)}}, - {50u, {eprosima::fastdds::rtps::octet(7), false, std::uint16_t(555), std::int16_t(20)}}, - {600u, {eprosima::fastdds::rtps::octet(0), true, std::uint16_t(0), std::int16_t(0)}} + const std::unordered_map> value { + {100u, {std::uint8_t(5), true, std::uint16_t(1000), std::int16_t(2000)}}, + {50u, {std::uint8_t(7), false, std::uint16_t(555), std::int16_t(20)}}, + {600u, {std::uint8_t(0), true, std::uint16_t(0), std::int16_t(0)}} }; - eprosima::fastdds::rtps::octet test_value1; + uint8_t test_value1; bool test_value2; uint16_t test_value3; int16_t test_value4; @@ -11837,7 +11837,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapULongLongInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->set_byte_value(inner_bitset->get_member_id_by_name(bitfield_a), + inner_bitset->set_uint8_value(inner_bitset->get_member_id_by_name(bitfield_a), std::get<0>(map_element.second))); EXPECT_EQ(RETCODE_OK, inner_bitset->set_boolean_value(inner_bitset->get_member_id_by_name(bitfield_b), @@ -11857,7 +11857,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapULongLongInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(std::to_string(map_element.first))); EXPECT_EQ(RETCODE_OK, - inner_bitset->get_byte_value(test_value1, + inner_bitset->get_uint8_value(test_value1, inner_bitset->get_member_id_by_name(bitfield_a))); EXPECT_EQ(std::get<0>(map_element.second), test_value1); EXPECT_EQ(RETCODE_OK, @@ -13718,12 +13718,12 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapStringInnerBitsetHelper) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - const std::unordered_map> value { - {"we", {eprosima::fastdds::rtps::octet(5), true, std::uint16_t(1000), std::int16_t(2000)}}, - {"are", {eprosima::fastdds::rtps::octet(7), false, std::uint16_t(555), std::int16_t(20)}}, - {"testing", {eprosima::fastdds::rtps::octet(0), true, std::uint16_t(0), std::int16_t(0)}} + const std::unordered_map> value { + {"we", {std::uint8_t(5), true, std::uint16_t(1000), std::int16_t(2000)}}, + {"are", {std::uint8_t(7), false, std::uint16_t(555), std::int16_t(20)}}, + {"testing", {std::uint8_t(0), true, std::uint16_t(0), std::int16_t(0)}} }; - eprosima::fastdds::rtps::octet test_value1; + uint8_t test_value1; bool test_value2; uint16_t test_value3; int16_t test_value4; @@ -13735,7 +13735,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapStringInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(map_element.first)); EXPECT_EQ(RETCODE_OK, - inner_bitset->set_byte_value(inner_bitset->get_member_id_by_name(bitfield_a), + inner_bitset->set_uint8_value(inner_bitset->get_member_id_by_name(bitfield_a), std::get<0>(map_element.second))); EXPECT_EQ(RETCODE_OK, inner_bitset->set_boolean_value(inner_bitset->get_member_id_by_name(bitfield_b), @@ -13755,7 +13755,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapStringInnerBitsetHelper) auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(map_element.first)); EXPECT_EQ(RETCODE_OK, - inner_bitset->get_byte_value(test_value1, + inner_bitset->get_uint8_value(test_value1, inner_bitset->get_member_id_by_name(bitfield_a))); EXPECT_EQ(std::get<0>(map_element.second), test_value1); EXPECT_EQ(RETCODE_OK, @@ -15614,12 +15614,12 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapInnerAliasBoundedStringHelperIn DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - const std::unordered_map> value { - {"we", {eprosima::fastdds::rtps::octet(5), true, std::uint16_t(1000), std::int16_t(2000)}}, - {"are", {eprosima::fastdds::rtps::octet(7), false, std::uint16_t(555), std::int16_t(20)}}, - {"testing", {eprosima::fastdds::rtps::octet(0), true, std::uint16_t(0), std::int16_t(0)}} + const std::unordered_map> value { + {"we", {std::uint8_t(5), true, std::uint16_t(1000), std::int16_t(2000)}}, + {"are", {std::uint8_t(7), false, std::uint16_t(555), std::int16_t(20)}}, + {"testing", {std::uint8_t(0), true, std::uint16_t(0), std::int16_t(0)}} }; - eprosima::fastdds::rtps::octet test_value1; + uint8_t test_value1; bool test_value2; uint16_t test_value3; int16_t test_value4; @@ -15632,7 +15632,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapInnerAliasBoundedStringHelperIn auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(map_element.first)); EXPECT_EQ(RETCODE_OK, - inner_bitset->set_byte_value(inner_bitset->get_member_id_by_name(bitfield_a), + inner_bitset->set_uint8_value(inner_bitset->get_member_id_by_name(bitfield_a), std::get<0>(map_element.second))); EXPECT_EQ(RETCODE_OK, inner_bitset->set_boolean_value(inner_bitset->get_member_id_by_name(bitfield_b), @@ -15652,7 +15652,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_MapInnerAliasBoundedStringHelperIn auto inner_bitset = map_data->loan_value(map_data->get_member_id_by_name(map_element.first)); EXPECT_EQ(RETCODE_OK, - inner_bitset->get_byte_value(test_value1, + inner_bitset->get_uint8_value(test_value1, inner_bitset->get_member_id_by_name(bitfield_a))); EXPECT_EQ(std::get<0>(map_element.second), test_value1); EXPECT_EQ(RETCODE_OK, diff --git a/test/feature/dynamic_types/dds_types_tests/DynamicTypesSequencesDDSTypesTests.cpp b/test/feature/dynamic_types/dds_types_tests/DynamicTypesSequencesDDSTypesTests.cpp index 8279ca58272..3045be4ee6e 100644 --- a/test/feature/dynamic_types/dds_types_tests/DynamicTypesSequencesDDSTypesTests.cpp +++ b/test/feature/dynamic_types/dds_types_tests/DynamicTypesSequencesDDSTypesTests.cpp @@ -1237,9 +1237,9 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_SequenceBitset) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - eprosima::fastdds::rtps::octet first_octet_value = 5; - eprosima::fastdds::rtps::octet second_octet_value = 7; - eprosima::fastdds::rtps::octet test_octet_value = 0; + uint8_t first_uint8_value = 5; + uint8_t second_uint8_value = 7; + uint8_t test_uint8_value = 0; bool first_bool_value = true; bool second_bool_value = false; bool test_bool_value = false; @@ -1253,11 +1253,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_SequenceBitset) ASSERT_TRUE(seq_data); DynamicData::_ref_type bitset_data = seq_data->loan_value(0); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), first_octet_value), + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), first_uint8_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(first_octet_value, test_octet_value); + EXPECT_EQ(first_uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name( bitfield_b), first_bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( @@ -1276,11 +1276,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_SequenceBitset) EXPECT_EQ(seq_data->return_loaned_value(bitset_data), RETCODE_OK); bitset_data = seq_data->loan_value(1); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name( - bitfield_a), second_octet_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name( + bitfield_a), second_uint8_value), RETCODE_OK); + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(second_octet_value, test_octet_value); + EXPECT_EQ(second_uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name( bitfield_b), second_bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( @@ -1307,11 +1307,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_SequenceBitset) seq_data = data->loan_value(data->get_member_id_by_name(var_bitset_seq)); ASSERT_TRUE(seq_data); EXPECT_EQ(struct_data.var_sequence_bitset().size(), seq_data->get_item_count()); - EXPECT_EQ(struct_data.var_sequence_bitset()[0].a, first_octet_value); + EXPECT_EQ(struct_data.var_sequence_bitset()[0].a, first_uint8_value); EXPECT_EQ(struct_data.var_sequence_bitset()[0].b, first_bool_value); EXPECT_EQ(struct_data.var_sequence_bitset()[0].c, first_ushort_value); EXPECT_EQ(struct_data.var_sequence_bitset()[0].d, first_short_value); - EXPECT_EQ(struct_data.var_sequence_bitset()[1].a, second_octet_value); + EXPECT_EQ(struct_data.var_sequence_bitset()[1].a, second_uint8_value); EXPECT_EQ(struct_data.var_sequence_bitset()[1].b, second_bool_value); EXPECT_EQ(struct_data.var_sequence_bitset()[1].c, second_ushort_value); EXPECT_EQ(struct_data.var_sequence_bitset()[1].d, second_short_value); diff --git a/test/feature/dynamic_types/dds_types_tests/DynamicTypesStructuresDDSTypesTests.cpp b/test/feature/dynamic_types/dds_types_tests/DynamicTypesStructuresDDSTypesTests.cpp index dca74ca7cdc..70957a55600 100644 --- a/test/feature/dynamic_types/dds_types_tests/DynamicTypesStructuresDDSTypesTests.cpp +++ b/test/feature/dynamic_types/dds_types_tests/DynamicTypesStructuresDDSTypesTests.cpp @@ -1286,8 +1286,8 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_StructBitset) DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; ASSERT_TRUE(data); - eprosima::fastdds::rtps::octet octet_value = 5; - eprosima::fastdds::rtps::octet test_octet_value = 0; + uint8_t uint8_value = 5; + uint8_t test_uint8_value = 0; bool bool_value = true; bool test_bool_value = false; uint16_t ushort_value = 1000; @@ -1296,10 +1296,10 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_StructBitset) int16_t test_short_value = 0; DynamicData::_ref_type bitset_data = data->loan_value(data->get_member_id_by_name(var_bitset_name)); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), octet_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), uint8_value), RETCODE_OK); + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(octet_value, test_octet_value); + EXPECT_EQ(uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name(bitfield_b), bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( bitfield_b)), RETCODE_OK); @@ -1319,7 +1319,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_StructBitset) StructBitset data_struct; TypeSupport static_pubsubType {new StructBitsetPubSubType()}; check_serialization_deserialization(struct_type, data, encoding, data_struct, static_pubsubType); - EXPECT_EQ(data_struct.var_bitset().a, test_octet_value); + EXPECT_EQ(data_struct.var_bitset().a, test_uint8_value); EXPECT_EQ(data_struct.var_bitset().b, test_bool_value); EXPECT_EQ(data_struct.var_bitset().c, test_ushort_value); EXPECT_EQ(data_struct.var_bitset().d, test_short_value); @@ -1370,7 +1370,7 @@ struct testing_values_struct Int16Seq test_array_value; Int32Seq test_seq_value; int32_t test_map_value; - eprosima::fastdds::rtps::octet test_octet_value; + uint8_t test_uint8_value; }; void check_structure_static_data( @@ -1415,7 +1415,7 @@ void check_structure_static_data( EXPECT_EQ(struct_data.var_StructUnion().var_union().shortValue(), testing_values.test_short_value); EXPECT_EQ(struct_data.var_StructStructure().var_structure().field1(), testing_values.test_long_value); EXPECT_EQ(struct_data.var_StructStructure().var_structure().field2(), testing_values.test_float_value); - EXPECT_EQ(struct_data.var_StructBitset().var_bitset().a, testing_values.test_octet_value); + EXPECT_EQ(struct_data.var_StructBitset().var_bitset().a, testing_values.test_uint8_value); EXPECT_EQ(struct_data.var_StructBitset().var_bitset().b, testing_values.test_bool_value); EXPECT_EQ(struct_data.var_StructBitset().var_bitset().c, testing_values.test_ushort_value); EXPECT_EQ(struct_data.var_StructBitset().var_bitset().d, testing_values.test_short_value); @@ -1567,7 +1567,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_StructStructures) Int16Seq array_value = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Int32Seq seq_value = {10, 20}; int32_t map_value = 253; - eprosima::fastdds::rtps::octet octet_value = 7; + uint8_t uint8_value = 7; testing_values_struct testing_values; DynamicData::_ref_type short_struct_data = data->loan_value(data->get_member_id_by_name(var_short_struct_name)); @@ -1787,11 +1787,11 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_StructStructures) testing_values.test_bool_value = false; testing_values.test_ushort_value = 0; testing_values.test_short_value = 0; - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), octet_value), RETCODE_OK); + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), uint8_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name(bitfield_b), bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_uint16_value(bitset_data->get_member_id_by_name(bitfield_c), ushort_value), RETCODE_OK); EXPECT_EQ(bitset_data->set_int16_value(bitset_data->get_member_id_by_name(bitfield_d), short_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(testing_values.test_octet_value, + EXPECT_EQ(bitset_data->get_uint8_value(testing_values.test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(testing_values.test_bool_value, bitset_data->get_member_id_by_name(bitfield_b)), RETCODE_OK); @@ -1799,7 +1799,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_StructStructures) bitset_data->get_member_id_by_name(bitfield_c)), RETCODE_OK); EXPECT_EQ(bitset_data->get_int16_value(testing_values.test_short_value, bitset_data->get_member_id_by_name(bitfield_d)), RETCODE_OK); - EXPECT_EQ(octet_value, testing_values.test_octet_value); + EXPECT_EQ(uint8_value, testing_values.test_uint8_value); EXPECT_EQ(bool_value, testing_values.test_bool_value); EXPECT_EQ(ushort_value, testing_values.test_ushort_value); EXPECT_EQ(short_value, testing_values.test_short_value); diff --git a/test/feature/dynamic_types/dds_types_tests/DynamicTypesUnionsDDSTypesTests.cpp b/test/feature/dynamic_types/dds_types_tests/DynamicTypesUnionsDDSTypesTests.cpp index a35fad57614..98a705460ae 100644 --- a/test/feature/dynamic_types/dds_types_tests/DynamicTypesUnionsDDSTypesTests.cpp +++ b/test/feature/dynamic_types/dds_types_tests/DynamicTypesUnionsDDSTypesTests.cpp @@ -1630,8 +1630,8 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_UnionInnerBitsetHelper) DynamicData::_ref_type union_data = data->loan_value(data->get_member_id_by_name(var_union_bitset_name)); ASSERT_TRUE(union_data); - eprosima::fastdds::rtps::octet octet_value = 5; - eprosima::fastdds::rtps::octet test_octet_value = 0; + uint8_t uint8_value = 5; + uint8_t test_uint8_value = 0; bool bool_value = true; bool test_bool_value = false; uint16_t ushort_value = 1000; @@ -1640,10 +1640,10 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_UnionInnerBitsetHelper) int16_t test_short_value = 0; DynamicData::_ref_type bitset_data = union_data->loan_value(union_data->get_member_id_by_name(var_union_member_x)); ASSERT_TRUE(bitset_data); - EXPECT_EQ(bitset_data->set_byte_value(bitset_data->get_member_id_by_name(bitfield_a), octet_value), RETCODE_OK); - EXPECT_EQ(bitset_data->get_byte_value(test_octet_value, bitset_data->get_member_id_by_name(bitfield_a)), + EXPECT_EQ(bitset_data->set_uint8_value(bitset_data->get_member_id_by_name(bitfield_a), uint8_value), RETCODE_OK); + EXPECT_EQ(bitset_data->get_uint8_value(test_uint8_value, bitset_data->get_member_id_by_name(bitfield_a)), RETCODE_OK); - EXPECT_EQ(octet_value, test_octet_value); + EXPECT_EQ(uint8_value, test_uint8_value); EXPECT_EQ(bitset_data->set_boolean_value(bitset_data->get_member_id_by_name(bitfield_b), bool_value), RETCODE_OK); EXPECT_EQ(bitset_data->get_boolean_value(test_bool_value, bitset_data->get_member_id_by_name( bitfield_b)), RETCODE_OK); @@ -1665,7 +1665,7 @@ TEST_F(DynamicTypesDDSTypesTest, DDSTypesTest_UnionInnerBitsetHelper) TypeSupport static_pubsubType {new UnionInnerBitsetHelperPubSubType()}; check_serialization_deserialization(struct_type, data, encoding, struct_data, static_pubsubType); - EXPECT_EQ(struct_data.var_union_my_bitset().x().a, test_octet_value); + EXPECT_EQ(struct_data.var_union_my_bitset().x().a, test_uint8_value); EXPECT_EQ(struct_data.var_union_my_bitset().x().b, test_bool_value); EXPECT_EQ(struct_data.var_union_my_bitset().x().c, test_ushort_value); EXPECT_EQ(struct_data.var_union_my_bitset().x().d, test_short_value); diff --git a/test/performance/latency/LatencyTestPublisher.cpp b/test/performance/latency/LatencyTestPublisher.cpp index 5b428e5799c..7d0d3df48c3 100644 --- a/test/performance/latency/LatencyTestPublisher.cpp +++ b/test/performance/latency/LatencyTestPublisher.cpp @@ -711,8 +711,8 @@ bool LatencyTestPublisher::test( if (dynamic_types_) { - dynamic_data_in_ = static_cast(dynamic_pub_sub_type_->createData()); - dynamic_data_out_ = static_cast(dynamic_pub_sub_type_->createData()); + dynamic_data_in_ = static_cast(dynamic_pub_sub_type_->create_data()); + dynamic_data_out_ = static_cast(dynamic_pub_sub_type_->create_data()); if (nullptr == dynamic_data_in_) { @@ -750,11 +750,11 @@ bool LatencyTestPublisher::test( if (!data_loans_) { // Create the reception data sample - latency_data_in_ = static_cast(latency_data_type_->createData()); + latency_data_in_ = static_cast(latency_data_type_->create_data()); } // On loans scenario this object will be kept only to check the echoed sample is correct // On the ordinary case it keeps the object to send - latency_data_out_ = static_cast(latency_data_type_->createData()); + latency_data_out_ = static_cast(latency_data_type_->create_data()); } else { @@ -898,8 +898,8 @@ bool LatencyTestPublisher::test( // Delete Data Sample if (dynamic_types_) { - dynamic_pub_sub_type_->deleteData(dynamic_data_in_); - dynamic_pub_sub_type_->deleteData(dynamic_data_out_); + dynamic_pub_sub_type_->delete_data(dynamic_data_in_); + dynamic_pub_sub_type_->delete_data(dynamic_data_out_); } else { diff --git a/test/performance/latency/LatencyTestSubscriber.cpp b/test/performance/latency/LatencyTestSubscriber.cpp index 99a4fc856b1..6e82cd5aaf2 100644 --- a/test/performance/latency/LatencyTestSubscriber.cpp +++ b/test/performance/latency/LatencyTestSubscriber.cpp @@ -661,7 +661,7 @@ bool LatencyTestSubscriber::test( if (dynamic_types_) { // Create the data sample - dynamic_data_ = static_cast(dynamic_pub_sub_type_->createData()); + dynamic_data_ = static_cast(dynamic_pub_sub_type_->create_data()); if (nullptr == dynamic_data_) { @@ -727,7 +727,7 @@ bool LatencyTestSubscriber::test( if (dynamic_types_) { - dynamic_pub_sub_type_->deleteData(dynamic_data_); + dynamic_pub_sub_type_->delete_data(dynamic_data_); // // Reset history for the new test size_t removed; @@ -736,7 +736,7 @@ bool LatencyTestSubscriber::test( else { // release the buffer next iteration will require different size - latency_data_type_->deleteData(latency_data_); + latency_data_type_->delete_data(latency_data_); // Remove endpoints associated to the given payload size if (!destroy_data_endpoints()) diff --git a/test/performance/latency/LatencyTestTypes.cpp b/test/performance/latency/LatencyTestTypes.cpp index 199db866174..d863f621c50 100644 --- a/test/performance/latency/LatencyTestTypes.cpp +++ b/test/performance/latency/LatencyTestTypes.cpp @@ -55,13 +55,13 @@ void LatencyDataType::copy_data( bool LatencyDataType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t) { static uint8_t encapsulation[4] = { 0x0, 0x1, 0x0, 0x0 }; LatencyType* lt = (LatencyType*)data; - auto ser_data = payload->data; + auto ser_data = payload.data; memcpy(ser_data, encapsulation, SerializedPayload_t::representation_header_size); ser_data += SerializedPayload_t::representation_header_size; memcpy(ser_data, <->seqnum, sizeof(lt->seqnum)); @@ -69,17 +69,17 @@ bool LatencyDataType::serialize( memcpy(ser_data, <->bounce, sizeof(lt->bounce)); ser_data += sizeof(lt->bounce); memcpy(ser_data, lt->data, buffer_size_); - payload->length = m_typeSize; + payload.length = max_serialized_type_size; return true; } bool LatencyDataType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { // Payload members endianness matches local machine LatencyType* lt = (LatencyType*)data; - auto ser_data = payload->data + SerializedPayload_t::representation_header_size; + auto ser_data = payload.data + SerializedPayload_t::representation_header_size; lt->seqnum = *reinterpret_cast(ser_data); ser_data += sizeof(lt->seqnum); lt->bounce = *reinterpret_cast(ser_data); @@ -88,23 +88,19 @@ bool LatencyDataType::deserialize( return true; } -std::function LatencyDataType::getSerializedSizeProvider( +uint32_t LatencyDataType::calculate_serialized_size( const void* const, eprosima::fastdds::dds::DataRepresentationId_t) { - uint32_t size = m_typeSize; - return [size]() -> uint32_t - { - return size; - }; + return max_serialized_type_size; } -void* LatencyDataType::createData() +void* LatencyDataType::create_data() { - return (void*)new uint8_t[m_typeSize]; + return (void*)new uint8_t[max_serialized_type_size]; } -void LatencyDataType::deleteData( +void LatencyDataType::delete_data( void* data) { delete[] (uint8_t*)(data); @@ -112,48 +108,45 @@ void LatencyDataType::deleteData( bool TestCommandDataType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t) { TestCommandType* t = (TestCommandType*)data; - memcpy(payload->data, &t->m_command, sizeof(t->m_command)); - payload->length = 4; + memcpy(payload.data, &t->m_command, sizeof(t->m_command)); + payload.length = 4; return true; } bool TestCommandDataType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { TestCommandType* t = (TestCommandType*)data; // cout << "PAYLOAD LENGTH: "<length << endl; // cout << "PAYLOAD FIRST BYTE: "<< (int)payload->data[0] << endl; - memcpy(&t->m_command, payload->data, sizeof(payload->length)); + memcpy(&t->m_command, payload.data, sizeof(payload.length)); // cout << "COMMAND: "<m_command<< endl; return true; } -std::function TestCommandDataType::getSerializedSizeProvider( +uint32_t TestCommandDataType::calculate_serialized_size( const void* const, eprosima::fastdds::dds::DataRepresentationId_t) { - return []() -> uint32_t - { - uint32_t size = 0; + uint32_t size = 0; - size = (uint32_t)sizeof(uint32_t); + size = (uint32_t)sizeof(uint32_t); - return size; - }; + return size; } -void* TestCommandDataType::createData() +void* TestCommandDataType::create_data() { return (void*)new TestCommandType(); } -void TestCommandDataType::deleteData( +void TestCommandDataType::delete_data( void* data) { diff --git a/test/performance/latency/LatencyTestTypes.hpp b/test/performance/latency/LatencyTestTypes.hpp index 7c5e78aaa5b..24ab0f406dc 100644 --- a/test/performance/latency/LatencyTestTypes.hpp +++ b/test/performance/latency/LatencyTestTypes.hpp @@ -83,21 +83,21 @@ class LatencyDataType : public eprosima::fastdds::dds::TopicDataType LatencyDataType() : buffer_size_(MAX_TYPE_SIZE - LatencyType::overhead) { - setName("LatencyType"); - m_typeSize = MAX_TYPE_SIZE; - m_isGetKeyDefined = false; + set_name("LatencyType"); + max_serialized_type_size = MAX_TYPE_SIZE; + is_compute_key_provided = false; } LatencyDataType( const size_t& size) : buffer_size_(size) { - setName("LatencyType"); - m_typeSize = sizeof(decltype(LatencyType::seqnum)) + + set_name("LatencyType"); + max_serialized_type_size = sizeof(decltype(LatencyType::seqnum)) + sizeof(decltype(LatencyType::bounce)) + ((size + 3) & ~3) + eprosima::fastdds::rtps::SerializedPayload_t::representation_header_size; - m_isGetKeyDefined = false; + is_compute_key_provided = false; } ~LatencyDataType() @@ -106,33 +106,31 @@ class LatencyDataType : public eprosima::fastdds::dds::TopicDataType bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - void* createData() override; - void deleteData( + void* create_data() override; + void delete_data( void* data) override; - bool getKey( + + bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool force_md5 = false) override + { + (void)force_md5; + return false; + } + + bool compute_key( const void* const /*data*/, - eprosima::fastdds::rtps::InstanceHandle_t* /*ihandle*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool force_md5 = false) override { (void)force_md5; @@ -149,11 +147,11 @@ class LatencyDataType : public eprosima::fastdds::dds::TopicDataType bool is_bounded() const override { - // All plain types are bounded - return is_plain(); + return true; } - bool is_plain() const override + bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t) const override { // It is plain because the type has a fixed size return true; @@ -199,9 +197,9 @@ class TestCommandDataType : public eprosima::fastdds::dds::TopicDataType TestCommandDataType() { - setName("TestCommandType"); - m_typeSize = 4; - m_isGetKeyDefined = false; + set_name("TestCommandType"); + max_serialized_type_size = 4; + is_compute_key_provided = false; } ~TestCommandDataType() @@ -210,33 +208,31 @@ class TestCommandDataType : public eprosima::fastdds::dds::TopicDataType bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - void* createData() override; - void deleteData( + void* create_data() override; + void delete_data( void* data) override; - bool getKey( + + bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool force_md5 = false) override + { + (void)force_md5; + return false; + } + + bool compute_key( const void* const /*data*/, - eprosima::fastdds::rtps::InstanceHandle_t* /*ihandle*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool force_md5 = false) override { (void)force_md5; diff --git a/test/performance/throughput/ThroughputPublisher.cpp b/test/performance/throughput/ThroughputPublisher.cpp index de5724e0b1d..ace865f662d 100644 --- a/test/performance/throughput/ThroughputPublisher.cpp +++ b/test/performance/throughput/ThroughputPublisher.cpp @@ -549,7 +549,7 @@ void ThroughputPublisher::run( { assert(nullptr == dynamic_data_); // Create the data sample - dynamic_data_ = static_cast(dynamic_pub_sub_type_->createData()); + dynamic_data_ = static_cast(dynamic_pub_sub_type_->create_data()); if (nullptr == dynamic_data_) { diff --git a/test/performance/throughput/ThroughputSubscriber.cpp b/test/performance/throughput/ThroughputSubscriber.cpp index 6648c643b5a..be1d00ab352 100644 --- a/test/performance/throughput/ThroughputSubscriber.cpp +++ b/test/performance/throughput/ThroughputSubscriber.cpp @@ -558,7 +558,7 @@ int ThroughputSubscriber::process_message() // Create the data sample dynamic_data_ = - static_cast(dynamic_pub_sub_type_->createData()); + static_cast(dynamic_pub_sub_type_->create_data()); if (nullptr == dynamic_data_) { diff --git a/test/performance/throughput/ThroughputTypes.cpp b/test/performance/throughput/ThroughputTypes.cpp index 2a5ece392e4..c5f1eedfa8c 100644 --- a/test/performance/throughput/ThroughputTypes.cpp +++ b/test/performance/throughput/ThroughputTypes.cpp @@ -43,31 +43,31 @@ bool ThroughputDataType::compare_data( // Serialization and deserialization functions bool ThroughputDataType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t) { static uint8_t encapsulation[4] = { 0x0, 0x1, 0x0, 0x0 }; ThroughputType* lt = (ThroughputType*)data; - auto ser_data = payload->data; + auto ser_data = payload.data; memcpy(ser_data, encapsulation, SerializedPayload_t::representation_header_size); ser_data += SerializedPayload_t::representation_header_size; memcpy(ser_data, <->seqnum, sizeof(lt->seqnum)); ser_data += sizeof(lt->seqnum); memcpy(ser_data, lt->data, buffer_size_); - payload->length = m_typeSize; + payload.length = max_serialized_type_size; return true; } bool ThroughputDataType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { - if (payload->length > 0) + if (payload.length > 0) { // payload members endiannes matches local machine ThroughputType* lt = (ThroughputType*)data; - auto ser_data = payload->data + SerializedPayload_t::representation_header_size; + auto ser_data = payload.data + SerializedPayload_t::representation_header_size; lt->seqnum = *reinterpret_cast(ser_data); ser_data += sizeof(lt->seqnum); std::copy(ser_data, ser_data + buffer_size_, lt->data); @@ -75,24 +75,20 @@ bool ThroughputDataType::deserialize( return true; } -std::function ThroughputDataType::getSerializedSizeProvider( +uint32_t ThroughputDataType::calculate_serialized_size( const void* const, eprosima::fastdds::dds::DataRepresentationId_t) { // uint32_t seqnum + uint32_t buffer_size_ + actual data - uint32_t size = m_typeSize; - return [size]() -> uint32_t - { - return size; - }; + return max_serialized_type_size; } -void* ThroughputDataType::createData() +void* ThroughputDataType::create_data() { - return (void*)new uint8_t[m_typeSize]; + return (void*)new uint8_t[max_serialized_type_size]; } -void ThroughputDataType::deleteData( +void ThroughputDataType::delete_data( void* data) { delete[] (uint8_t*)(data); @@ -100,75 +96,72 @@ void ThroughputDataType::deleteData( bool ThroughputCommandDataType::serialize( const void* const data, - SerializedPayload_t* p, + SerializedPayload_t& p, eprosima::fastdds::dds::DataRepresentationId_t) { ThroughputCommandType* t = (ThroughputCommandType*)data; - p->length = 0; + p.length = 0; const uint32_t command = t->m_command; - memcpy(p->data, &command, sizeof(command)); - p->length += sizeof(command); - memcpy(&p->data[p->length], &t->m_size, sizeof(t->m_size)); - p->length += sizeof(t->m_size); - memcpy(&p->data[p->length], &t->m_demand, sizeof(t->m_demand)); - p->length += sizeof(t->m_demand); - memcpy(&p->data[p->length], &t->m_lostsamples, sizeof(t->m_lostsamples)); - p->length += sizeof(t->m_lostsamples); - memcpy(&p->data[p->length], &t->m_receivedsamples, sizeof(t->m_receivedsamples)); - p->length += sizeof(t->m_receivedsamples); - memcpy(&p->data[p->length], &t->m_lastrecsample, sizeof(t->m_lastrecsample)); - p->length += sizeof(t->m_lastrecsample); - memcpy(&p->data[p->length], &t->m_totaltime, sizeof(t->m_totaltime)); - p->length += sizeof(t->m_totaltime); + memcpy(p.data, &command, sizeof(command)); + p.length += sizeof(command); + memcpy(&p.data[p.length], &t->m_size, sizeof(t->m_size)); + p.length += sizeof(t->m_size); + memcpy(&p.data[p.length], &t->m_demand, sizeof(t->m_demand)); + p.length += sizeof(t->m_demand); + memcpy(&p.data[p.length], &t->m_lostsamples, sizeof(t->m_lostsamples)); + p.length += sizeof(t->m_lostsamples); + memcpy(&p.data[p.length], &t->m_receivedsamples, sizeof(t->m_receivedsamples)); + p.length += sizeof(t->m_receivedsamples); + memcpy(&p.data[p.length], &t->m_lastrecsample, sizeof(t->m_lastrecsample)); + p.length += sizeof(t->m_lastrecsample); + memcpy(&p.data[p.length], &t->m_totaltime, sizeof(t->m_totaltime)); + p.length += sizeof(t->m_totaltime); return true; } bool ThroughputCommandDataType::deserialize( - SerializedPayload_t* p, + SerializedPayload_t& p, void* data) { ThroughputCommandType* t = (ThroughputCommandType*)data; - p->pos = 0; + p.pos = 0; uint32_t command; - memcpy(&command, p->data, sizeof(command)); + memcpy(&command, p.data, sizeof(command)); t->m_command = static_cast(command); - p->pos += sizeof(command); - memcpy(&t->m_size, &p->data[p->pos], sizeof(t->m_size)); - p->pos += sizeof(t->m_size); - memcpy(&t->m_demand, &p->data[p->pos], sizeof(t->m_demand)); - p->pos += sizeof(t->m_demand); - memcpy(&t->m_lostsamples, &p->data[p->pos], sizeof(t->m_lostsamples)); - p->pos += sizeof(t->m_lostsamples); - memcpy(&t->m_receivedsamples, &p->data[p->pos], sizeof(t->m_receivedsamples)); - p->pos += sizeof(t->m_receivedsamples); - memcpy(&t->m_lastrecsample, &p->data[p->pos], sizeof(t->m_lastrecsample)); - p->pos += sizeof(t->m_lastrecsample); - memcpy(&t->m_totaltime, &p->data[p->pos], sizeof(t->m_totaltime)); - p->pos += sizeof(t->m_totaltime); + p.pos += sizeof(command); + memcpy(&t->m_size, &p.data[p.pos], sizeof(t->m_size)); + p.pos += sizeof(t->m_size); + memcpy(&t->m_demand, &p.data[p.pos], sizeof(t->m_demand)); + p.pos += sizeof(t->m_demand); + memcpy(&t->m_lostsamples, &p.data[p.pos], sizeof(t->m_lostsamples)); + p.pos += sizeof(t->m_lostsamples); + memcpy(&t->m_receivedsamples, &p.data[p.pos], sizeof(t->m_receivedsamples)); + p.pos += sizeof(t->m_receivedsamples); + memcpy(&t->m_lastrecsample, &p.data[p.pos], sizeof(t->m_lastrecsample)); + p.pos += sizeof(t->m_lastrecsample); + memcpy(&t->m_totaltime, &p.data[p.pos], sizeof(t->m_totaltime)); + p.pos += sizeof(t->m_totaltime); return true; } -std::function ThroughputCommandDataType::getSerializedSizeProvider( +uint32_t ThroughputCommandDataType::calculate_serialized_size( const void* const, eprosima::fastdds::dds::DataRepresentationId_t) { - return []() -> uint32_t - { - uint32_t size = 0; + uint32_t size = 0; - size = (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + - sizeof(uint64_t) + sizeof(uint64_t) + sizeof(uint64_t)); + size = (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(uint64_t)); - return size; - }; + return size; } -void* ThroughputCommandDataType::createData() +void* ThroughputCommandDataType::create_data() { return (void*)new ThroughputCommandType(); } -void ThroughputCommandDataType::deleteData( +void ThroughputCommandDataType::delete_data( void* data) { delete((ThroughputCommandType*)data); diff --git a/test/performance/throughput/ThroughputTypes.hpp b/test/performance/throughput/ThroughputTypes.hpp index 171f57b299a..89855c09d5c 100644 --- a/test/performance/throughput/ThroughputTypes.hpp +++ b/test/performance/throughput/ThroughputTypes.hpp @@ -125,11 +125,11 @@ class ThroughputDataType : public eprosima::fastdds::dds::TopicDataType const uint32_t& size) : buffer_size_(size) { - setName(type_name_.c_str()); - m_typeSize = sizeof(decltype(ThroughputType::seqnum)) + + set_name(type_name_.c_str()); + max_serialized_type_size = sizeof(decltype(ThroughputType::seqnum)) + ((size + 3) & ~3) + eprosima::fastdds::rtps::SerializedPayload_t::representation_header_size; - m_isGetKeyDefined = false; + is_compute_key_provided = false; } ~ThroughputDataType() @@ -138,38 +138,34 @@ class ThroughputDataType : public eprosima::fastdds::dds::TopicDataType bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - void* createData() override; + void* create_data() override; - void deleteData( + void delete_data( void* data) override; - bool getKey( + bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool force_md5 = false) override + { + (void)force_md5; + return false; + } + + bool compute_key( const void* const /*data*/, - eprosima::fastdds::rtps::InstanceHandle_t* /*ihandle*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool force_md5 = false) override { (void)force_md5; @@ -182,11 +178,11 @@ class ThroughputDataType : public eprosima::fastdds::dds::TopicDataType bool is_bounded() const override { - // All plain types are bounded - return is_plain(); + return true; } - bool is_plain() const override + bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t /*data_representation*/) const override { // It is plain because the type has a fixed sized return true; @@ -257,9 +253,9 @@ class ThroughputCommandDataType : public eprosima::fastdds::dds::TopicDataType ThroughputCommandDataType() { - setName("ThroughputCommand"); - m_typeSize = 4 * sizeof(uint32_t) + 3 * sizeof(uint64_t) + sizeof(double); - m_isGetKeyDefined = false; + set_name("ThroughputCommand"); + max_serialized_type_size = 4 * sizeof(uint32_t) + 3 * sizeof(uint64_t) + sizeof(double); + is_compute_key_provided = false; } ~ThroughputCommandDataType() @@ -268,38 +264,34 @@ class ThroughputCommandDataType : public eprosima::fastdds::dds::TopicDataType bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - void* createData() override; + void* create_data() override; - void deleteData( + void delete_data( void* data) override; - bool getKey( + bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool force_md5 = false) override + { + (void)force_md5; + return false; + } + + bool compute_key( const void* const /*data*/, - eprosima::fastdds::rtps::InstanceHandle_t* /*ihandle*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool force_md5 = false) override { (void)force_md5; diff --git a/test/profiling/MemoryTestTypes.cpp b/test/profiling/MemoryTestTypes.cpp index ccef5eb9931..d2045327260 100644 --- a/test/profiling/MemoryTestTypes.cpp +++ b/test/profiling/MemoryTestTypes.cpp @@ -24,66 +24,50 @@ using namespace eprosima::fastdds::rtps; bool MemoryDataType::serialize( const void* const data, - SerializedPayload_t* payload) + SerializedPayload_t& payload, + eprosima::fastdds::dds::DataRepresentationId_t) { const MemoryType* lt = static_cast(data); - *(uint32_t*)payload->data = lt->seqnum; - *(uint32_t*)(payload->data + 4) = (uint32_t)lt->data.size(); + *(uint32_t*)payload.data = lt->seqnum; + *(uint32_t*)(payload.data + 4) = (uint32_t)lt->data.size(); - memcpy(payload->data + 8, lt->data.data(), lt->data.size()); - payload->length = static_cast(8 + lt->data.size()); + memcpy(payload.data + 8, lt->data.data(), lt->data.size()); + payload.length = static_cast(8 + lt->data.size()); return true; } -bool MemoryDataType::serialize( - const void* const data, - SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t) -{ - return serialize(data, payload); -} - bool MemoryDataType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { MemoryType* lt = static_cast(data); - lt->seqnum = static_cast(*(payload->data)); - uint32_t siz = static_cast(*(payload->data + 4)); - std::copy(payload->data + 8, payload->data + 8 + siz, lt->data.begin()); + lt->seqnum = static_cast(*(payload.data)); + uint32_t siz = static_cast(*(payload.data + 4)); + std::copy(payload.data + 8, payload.data + 8 + siz, lt->data.begin()); return true; } -std::function MemoryDataType::getSerializedSizeProvider( - const void* const data) -{ - return [data]() -> uint32_t - { - const MemoryType* tdata = static_cast(data); - uint32_t size = 0; - - size = static_cast(sizeof(uint32_t) + sizeof(uint32_t) + tdata->data.size()); - - return size; - }; -} - -std::function MemoryDataType::getSerializedSizeProvider( +uint32_t MemoryDataType::calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t) { - return getSerializedSizeProvider(data); + const MemoryType* tdata = static_cast(data); + uint32_t size = 0; + + size = static_cast(sizeof(uint32_t) + sizeof(uint32_t) + tdata->data.size()); + + return size; } -void* MemoryDataType::createData() +void* MemoryDataType::create_data() { return static_cast(new MemoryType()); } -void MemoryDataType::deleteData( +void MemoryDataType::delete_data( void* data) { @@ -92,58 +76,42 @@ void MemoryDataType::deleteData( bool TestCommandDataType::serialize( const void* const data, - SerializedPayload_t* payload) + SerializedPayload_t& payload, + eprosima::fastdds::dds::DataRepresentationId_t) { const TestCommandType* t = static_cast(data); - *(TESTCOMMAND*)payload->data = t->m_command; - payload->length = 4; + *(TESTCOMMAND*)payload.data = t->m_command; + payload.length = 4; return true; } -bool TestCommandDataType::serialize( - const void* const data, - SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t) -{ - return serialize(data, payload); -} - bool TestCommandDataType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { TestCommandType* t = static_cast(data); - t->m_command = static_cast(*(payload->data)); + t->m_command = static_cast(*(payload.data)); return true; } -std::function TestCommandDataType::getSerializedSizeProvider( - const void* const) +uint32_t TestCommandDataType::calculate_serialized_size( + const void* const, + eprosima::fastdds::dds::DataRepresentationId_t) { - return []() -> uint32_t - { - uint32_t size = 0; - - size = static_cast(sizeof(uint32_t)); + uint32_t size = 0; - return size; - }; -} + size = static_cast(sizeof(uint32_t)); -std::function TestCommandDataType::getSerializedSizeProvider( - const void* const data, - eprosima::fastdds::dds::DataRepresentationId_t) -{ - return getSerializedSizeProvider(data); + return size; } -void* TestCommandDataType::createData() +void* TestCommandDataType::create_data() { return static_cast(new TestCommandType()); } -void TestCommandDataType::deleteData( +void TestCommandDataType::delete_data( void* data) { diff --git a/test/profiling/MemoryTestTypes.h b/test/profiling/MemoryTestTypes.h index 3be55229e94..f0dc597b6c3 100644 --- a/test/profiling/MemoryTestTypes.h +++ b/test/profiling/MemoryTestTypes.h @@ -80,9 +80,9 @@ class MemoryDataType : public eprosima::fastdds::dds::TopicDataType MemoryDataType() { - setName("MemoryType"); - m_typeSize = 17000; - m_isGetKeyDefined = false; + set_name("MemoryType"); + max_serialized_type_size = 17000; + is_compute_key_provided = false; } ~MemoryDataType() @@ -91,25 +91,29 @@ class MemoryDataType : public eprosima::fastdds::dds::TopicDataType bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override; - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - std::function getSerializedSizeProvider( - const void* const data) override; - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - void* createData(); - void deleteData( - void* data); - bool getKey( + void* create_data() override; + void delete_data( + void* data) override; + bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool force_md5 = false) override + { + (void)force_md5; + return false; + } + + bool compute_key( const void* const /*data*/, - eprosima::fastdds::rtps::InstanceHandle_t* /*ihandle*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool force_md5 = false) override { (void)force_md5; @@ -149,9 +153,9 @@ class TestCommandDataType : public eprosima::fastdds::dds::TopicDataType TestCommandDataType() { - setName("TestCommandType"); - m_typeSize = 4; - m_isGetKeyDefined = false; + set_name("TestCommandType"); + max_serialized_type_size = 4; + is_compute_key_provided = false; } ~TestCommandDataType() @@ -160,25 +164,30 @@ class TestCommandDataType : public eprosima::fastdds::dds::TopicDataType bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override; - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - std::function getSerializedSizeProvider( - const void* const data) override; - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - void* createData(); - void deleteData( - void* data); - bool getKey( + void* create_data() override; + void delete_data( + void* data) override; + + bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool force_md5 = false) override + { + (void)force_md5; + return false; + } + + bool compute_key( const void* const /*data*/, - eprosima::fastdds::rtps::InstanceHandle_t* /*ihandle*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool force_md5 = false) override { (void)force_md5; diff --git a/test/profiling/allocations/AllocTestTypePubSubTypes.cxx b/test/profiling/allocations/AllocTestTypePubSubTypes.cxx index 6d98c6d2bf2..098f48976f2 100644 --- a/test/profiling/allocations/AllocTestTypePubSubTypes.cxx +++ b/test/profiling/allocations/AllocTestTypePubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; AllocTestTypePubSubType::AllocTestTypePubSubType() { - setName("AllocTestType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AllocTestType::getMaxCdrSerializedSize()); -#else - AllocTestType_max_cdr_typesize; -#endif + set_name("AllocTestType"); + uint32_t type_size = AllocTestType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AllocTestType_max_key_cdr_typesize > 16 ? AllocTestType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AllocTestType_max_key_cdr_typesize > 16 ? AllocTestType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AllocTestTypePubSubType::~AllocTestTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AllocTestTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AllocTestType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool AllocTestTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AllocTestTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool AllocTestTypePubSubType::deserialize( AllocTestType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool AllocTestTypePubSubType::deserialize( return true; } -std::function AllocTestTypePubSubType::getSerializedSizeProvider( +uint32_t AllocTestTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* AllocTestTypePubSubType::createData() +void* AllocTestTypePubSubType::create_data() { return reinterpret_cast(new AllocTestType()); } -void AllocTestTypePubSubType::deleteData( +void AllocTestTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AllocTestTypePubSubType::getKey( +bool AllocTestTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AllocTestType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AllocTestTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool AllocTestTypePubSubType::getKey( const AllocTestType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AllocTestType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AllocTestType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/profiling/allocations/AllocTestTypePubSubTypes.hpp b/test/profiling/allocations/AllocTestTypePubSubTypes.hpp index ffc3e93d584..bccb5a14989 100644 --- a/test/profiling/allocations/AllocTestTypePubSubTypes.hpp +++ b/test/profiling/allocations/AllocTestTypePubSubTypes.hpp @@ -32,10 +32,10 @@ #include "AllocTestType.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated AllocTestType is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class AllocTestTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class AllocTestTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class AllocTestTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index 9aacba03bec..e35f445c092 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -92,61 +92,53 @@ class TopicDataTypeMock : public TopicDataType TopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - setName("footype"); - } - - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + max_serialized_type_size = 4u; + set_name("footype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return []()->uint32_t - { - return 0; - }; + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -154,7 +146,7 @@ class TopicDataTypeMock : public TopicDataType void clearName() { - setName(""); + set_name(""); } }; @@ -166,54 +158,38 @@ class LoanableTopicDataTypeMock : public TopicDataType LoanableTopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - setName("loanablefootype"); - } - - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + max_serialized_type_size = 4u; + set_name("loanablefootype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return []()->uint32_t - { - return 0; - }; + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } @@ -223,20 +199,23 @@ class LoanableTopicDataTypeMock : public TopicDataType return true; } - inline bool is_plain() const override + inline bool is_plain( + DataRepresentationId_t) const override { return true; } - inline bool is_plain( - DataRepresentationId_t) const override + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override { return true; } - bool getKey( + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -3295,7 +3274,7 @@ TEST(ParticipantTests, DeleteContainedEntities) InstanceHandle_t handle_nil = HANDLE_NIL; BarType data; data.index(1); - type.get_key(&data, &handle_nil); + type.compute_key(&data, handle_nil); TypeSupport loanable_type(new LoanableTopicDataTypeMock()); loanable_type.register_type(participant); diff --git a/test/unittest/dds/publisher/CMakeLists.txt b/test/unittest/dds/publisher/CMakeLists.txt index 09d7162d0de..0d97d338001 100644 --- a/test/unittest/dds/publisher/CMakeLists.txt +++ b/test/unittest/dds/publisher/CMakeLists.txt @@ -70,7 +70,6 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/ContentFilteredTopicImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/qos/TopicQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/Topic.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicProxyFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TypeSupport.cpp diff --git a/test/unittest/dds/publisher/DataWriterTests.cpp b/test/unittest/dds/publisher/DataWriterTests.cpp index ccc278a988b..b03c678d68e 100644 --- a/test/unittest/dds/publisher/DataWriterTests.cpp +++ b/test/unittest/dds/publisher/DataWriterTests.cpp @@ -89,61 +89,53 @@ class TopicDataTypeMock : public TopicDataType TopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - setName("footype"); - } - - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + max_serialized_type_size = 4u; + set_name("footype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return []()->uint32_t - { - return 0; - }; + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -193,68 +185,57 @@ class InstanceTopicDataTypeMock : public TopicDataType InstanceTopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - m_isGetKeyDefined = true; - setName("instancefootype"); + max_serialized_type_size = 4u; + is_compute_key_provided = true; + set_name("instancefootype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/) override - { - return true; - } - - bool serialize( - const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const /*data*/) override - { - return []()->uint32_t - { - return 0; - }; - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return []()->uint32_t - { - return 0; - }; + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* ihandle, + fastdds::rtps::InstanceHandle_t& ihandle, bool /*force_md5*/) override { - ihandle->value[0] = 1; + ihandle.value[0] = 1; return true; } @@ -269,58 +250,53 @@ class BoundedTopicDataTypeMock : public TopicDataType BoundedTopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - setName("bounded_footype"); - } - - bool serialize( - const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/) override - { - return true; + max_serialized_type_size = 4u; + set_name("bounded_footype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const /*data*/) override - { - return std::function(); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return std::function(); + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -1070,7 +1046,7 @@ TEST(DataWriterTests, UnregisterInstance) // 7. Calling unregister_instance with a valid InstanceHandle also returns RETCODE_OK data.message("HelloWorld_1"); ASSERT_EQ(RETCODE_OK, instance_datawriter->write(&data, HANDLE_NIL)); - instance_type.get_key(&data, &handle); + instance_type->compute_key(&data, handle); EXPECT_EQ(RETCODE_OK, instance_datawriter->unregister_instance(&data, handle)); // TODO(jlbueno) There are other possible errors sending the unregister message: RETCODE_OUT_OF_RESOURCES, @@ -1125,7 +1101,7 @@ TEST(DataWriterTests, UnregisterInstanceWithTimestamp) // 7. Calling unregister_instance with a valid InstanceHandle also returns RETCODE_OK data.message("HelloWorld_1"); ASSERT_EQ(RETCODE_OK, instance_datawriter->write_w_timestamp(&data, HANDLE_NIL, ts)); - instance_type.get_key(&data, &handle); + instance_type.compute_key(&data, handle); EXPECT_EQ(RETCODE_OK, instance_datawriter->unregister_instance_w_timestamp(&data, handle, ts)); // 8. Check invalid timestamps @@ -1184,7 +1160,7 @@ TEST(DataWriterTests, Dispose) // 7. Calling dispose with a valid InstanceHandle also returns RETCODE_OK data.message("HelloWorld_1"); ASSERT_EQ(RETCODE_OK, instance_datawriter->write(&data, HANDLE_NIL)); - instance_type.get_key(&data, &handle); + instance_type.compute_key(&data, handle); EXPECT_EQ(RETCODE_OK, instance_datawriter->dispose(&data, handle)); // TODO(jlbueno) There are other possible errors sending the dispose message: RETCODE_OUT_OF_RESOURCES, @@ -1236,7 +1212,7 @@ TEST(DataWriterTests, DisposeWithTimestamp) // 7. Calling dispose with a valid InstanceHandle also returns RETCODE_OK data.message("HelloWorld_1"); ASSERT_EQ(RETCODE_OK, instance_datawriter->write_w_timestamp(&data, HANDLE_NIL, ts)); - instance_type.get_key(&data, &handle); + instance_type.compute_key(&data, handle); EXPECT_EQ(RETCODE_OK, instance_datawriter->dispose_w_timestamp(&data, handle, ts)); // 8. Check invalid timestamps @@ -1324,75 +1300,59 @@ class LoanableTypeSupport : public TopicDataType LoanableTypeSupport() : TopicDataType() { - m_typeSize = 4u + sizeof(LoanableType); - setName("LoanableType"); - } - - bool serialize( - const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/) override - { - return true; + max_serialized_type_size = 4u + sizeof(LoanableType); + set_name("LoanableType"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const /*data*/) override - { - return [this]() - { - return m_typeSize; - }; - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return [this]() - { - return m_typeSize; - }; + return max_serialized_type_size; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( - const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; } - bool is_bounded() const override + bool compute_key( + const void* const /*data*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override { return true; } - bool is_plain() const override + bool is_bounded() const override { return true; } @@ -1505,11 +1465,6 @@ class LoanableTypeSupportTesting : public LoanableTypeSupport bool is_plain_result = true; bool construct_sample_result = true; - bool is_plain() const override - { - return is_plain_result; - } - bool is_plain( DataRepresentationId_t) const override { @@ -1553,15 +1508,15 @@ TEST(DataWriterTests, LoanNegativeTests) ASSERT_EQ(datawriter->get_status_mask(), StatusMask::all()); void* sample = nullptr; - auto original_type_size = type_support->m_typeSize; + auto original_type_size = type_support->max_serialized_type_size; // Check for illegal operation type_support->is_plain_result = false; EXPECT_EQ(RETCODE_ILLEGAL_OPERATION, datawriter->loan_sample(sample)); type_support->is_plain_result = true; - type_support->m_typeSize = 0; + type_support->max_serialized_type_size = 0; EXPECT_EQ(RETCODE_ILLEGAL_OPERATION, datawriter->loan_sample(sample)); - type_support->m_typeSize = original_type_size; + type_support->max_serialized_type_size = original_type_size; // Check for not enabled EXPECT_EQ(RETCODE_NOT_ENABLED, datawriter->loan_sample(sample)); @@ -1686,7 +1641,7 @@ TEST(DataWriterTests, InstanceWaitForAcknowledgement) // Expectations EXPECT_CALL(*history, wait_for_acknowledgement_last_change(_, _, _)).WillOnce(testing::Return(true)); - instance_type.get_key(&data, &handle); + instance_type.compute_key(&data, handle); EXPECT_EQ(RETCODE_OK, instance_datawriter->wait_for_acknowledgments(&data, handle, max_wait)); // 7. Calling wait_for_acknowledgments in a keyed topic with a known handle timeouts if some reader has not @@ -1937,7 +1892,7 @@ TEST(DataWriterTests, InstancePolicyAllocationConsistencyKeyed) type.register_type(participant); // This test pretends to use topic with instances, so the following flag is set. - type.get()->m_isGetKeyDefined = true; + type.get()->is_compute_key_provided = true; Topic* topic = participant->create_topic("footopic", type.get_type_name(), TOPIC_QOS_DEFAULT); ASSERT_NE(topic, nullptr); @@ -2181,13 +2136,6 @@ class DataRepresentationTestsTypeSupport : public LoanableTypeSupport return custom_is_plain_with_rep(data_representation_id); } - MOCK_CONST_METHOD0(custom_is_plain, bool()); - - bool is_plain() const override - { - return custom_is_plain(); - } - }; TEST(DataWriterTests, data_type_is_plain_data_representation) @@ -2212,7 +2160,6 @@ TEST(DataWriterTests, data_type_is_plain_data_representation) qos_xcdr.endpoint().history_memory_policy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE; /* Expect the "is_plain" method called with default data representation (XCDR1) */ - EXPECT_CALL(*type, custom_is_plain()).Times(0); EXPECT_CALL(*type, custom_is_plain_with_rep(DataRepresentationId_t::XCDR_DATA_REPRESENTATION)).Times( testing::AtLeast(1)).WillRepeatedly(testing::Return(true)); EXPECT_CALL(*type, custom_is_plain_with_rep(DataRepresentationId_t::XCDR2_DATA_REPRESENTATION)).Times(0); @@ -2230,7 +2177,6 @@ TEST(DataWriterTests, data_type_is_plain_data_representation) qos_xcdr2.representation().m_value.push_back(DataRepresentationId_t::XCDR2_DATA_REPRESENTATION); /* Expect the "is_plain" method called with XCDR2 data representation */ - EXPECT_CALL(*type, custom_is_plain()).Times(0); EXPECT_CALL(*type, custom_is_plain_with_rep(DataRepresentationId_t::XCDR_DATA_REPRESENTATION)).Times(0); EXPECT_CALL(*type, custom_is_plain_with_rep(DataRepresentationId_t::XCDR2_DATA_REPRESENTATION)).Times( testing::AtLeast(1)).WillRepeatedly(testing::Return(true)); diff --git a/test/unittest/dds/publisher/PublisherTests.cpp b/test/unittest/dds/publisher/PublisherTests.cpp index 6b809967287..1f652654a17 100644 --- a/test/unittest/dds/publisher/PublisherTests.cpp +++ b/test/unittest/dds/publisher/PublisherTests.cpp @@ -40,61 +40,53 @@ class TopicDataTypeMock : public TopicDataType TopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - setName("footype"); - } - - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + max_serialized_type_size = 4u; + set_name("footype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return []()->uint32_t - { - return 0; - }; + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -109,51 +101,38 @@ class LoanableTopicDataTypeMock : public TopicDataType LoanableTopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - setName("loanablefootype"); - } - - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + max_serialized_type_size = 4u; + set_name("loanablefootype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return std::function(); + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } @@ -163,20 +142,23 @@ class LoanableTopicDataTypeMock : public TopicDataType return true; } - inline bool is_plain() const override + inline bool is_plain( + DataRepresentationId_t) const override { return true; } - inline bool is_plain( - DataRepresentationId_t) const override + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override { return true; } - bool getKey( + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; diff --git a/test/unittest/dds/status/CMakeLists.txt b/test/unittest/dds/status/CMakeLists.txt index be2d7bf2916..c46b27a808e 100644 --- a/test/unittest/dds/status/CMakeLists.txt +++ b/test/unittest/dds/status/CMakeLists.txt @@ -50,7 +50,6 @@ set(LISTENERTESTS_SOURCE ListenerTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/ContentFilteredTopicImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/qos/TopicQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/Topic.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicProxyFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TypeSupport.cpp diff --git a/test/unittest/dds/status/ListenerTests.cpp b/test/unittest/dds/status/ListenerTests.cpp index 6673accbfa3..6449364cdac 100644 --- a/test/unittest/dds/status/ListenerTests.cpp +++ b/test/unittest/dds/status/ListenerTests.cpp @@ -491,46 +491,53 @@ class TopicDataTypeMock : public TopicDataType TopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - setName("footype"); + max_serialized_type_size = 4u; + set_name("footype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/) override + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::dds::DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const /*data*/) override + uint32_t calculate_serialized_size( + const void* const /*data*/, + fastdds::dds::DataRepresentationId_t /*data_representation*/) override { - return []()->uint32_t - { - return 0; - }; + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -538,7 +545,7 @@ class TopicDataTypeMock : public TopicDataType private: - using TopicDataType::getSerializedSizeProvider; + using TopicDataType::calculate_serialized_size; using TopicDataType::serialize; }; diff --git a/test/unittest/dds/subscriber/CMakeLists.txt b/test/unittest/dds/subscriber/CMakeLists.txt index e2264079ca5..5150e36f204 100644 --- a/test/unittest/dds/subscriber/CMakeLists.txt +++ b/test/unittest/dds/subscriber/CMakeLists.txt @@ -25,7 +25,6 @@ set(DATAREADERINSTANCETESTS_SOURCE DataReaderInstanceTests.cpp ) set(DATAREADERHISTORYTESTS_SOURCE DataReaderHistoryTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/SerializedPayload.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp diff --git a/test/unittest/dds/subscriber/DataReaderHistoryTests.cpp b/test/unittest/dds/subscriber/DataReaderHistoryTests.cpp index 73924c24ec1..1b69e5672dc 100644 --- a/test/unittest/dds/subscriber/DataReaderHistoryTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderHistoryTests.cpp @@ -19,39 +19,36 @@ class TestType : public TopicDataType MOCK_METHOD(bool, serialize, ( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload), - (override)); - - MOCK_METHOD(bool, serialize, ( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, DataRepresentationId_t data_representation), - (override)); + (override)); MOCK_METHOD(bool, deserialize, ( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data), - (override)); + (override)); - MOCK_METHOD(std::function, getSerializedSizeProvider, ( + MOCK_METHOD(uint32_t, calculate_serialized_size, ( const void* const data, DataRepresentationId_t data_representation), - (override)); + (override)); - MOCK_METHOD(std::function, getSerializedSizeProvider, ( - const void* const data), - (override)); + MOCK_METHOD(void*, create_data, (), (override)); - MOCK_METHOD(void*, createData, (), (override)); - - MOCK_METHOD(void, deleteData, ( + MOCK_METHOD(void, delete_data, ( void* data), - (override)); + (override)); + + MOCK_METHOD(bool, compute_key, ( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::dds::InstanceHandle_t& ihandle, + bool), + (override)); - MOCK_METHOD(bool, getKey, ( + MOCK_METHOD(bool, compute_key, ( const void* const data, - eprosima::fastdds::dds::InstanceHandle_t* ihandle, + eprosima::fastdds::dds::InstanceHandle_t& ihandle, bool), - (override)); + (override)); }; /*! @@ -135,12 +132,9 @@ TEST(DataReaderHistory, exclusive_ownership_non_keyed_sample_reception) TEST(DataReaderHistory, exclusive_ownership_keyed_sample_reception) { TestType* type_ = new TestType(); - // These functions was called due to the type is keyed. - EXPECT_CALL(*type_, createData()).Times(1); - EXPECT_CALL(*type_, deleteData(nullptr)).Times(1); const TypeSupport type(type_); - type->m_isGetKeyDefined = true; + type->is_compute_key_provided = true; const Topic topic("test", "test"); DataReaderQos qos; qos.ownership().kind = eprosima::fastdds::dds::EXCLUSIVE_OWNERSHIP_QOS; diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index e57edf26986..c1c2e9da827 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -171,10 +171,10 @@ class DataReaderTests : public ::testing::Test FooType data; data.index(0); - type_.get_key(&data, &handle_ok_); + type_.compute_key(&data, handle_ok_); data.index(2); - type_.get_key(&data, &handle_wrong_); + type_.compute_key(&data, handle_wrong_); } void reset_lengths_if_ok( @@ -412,7 +412,7 @@ class DataReaderTests : public ::testing::Test // Return code when requesting a correct instance ReturnCode_t instance_ok_code = instance_bad_code; - if (RETCODE_OK == code && type_->m_isGetKeyDefined) + if (RETCODE_OK == code && type_->is_compute_key_provided) { instance_ok_code = code; } @@ -561,7 +561,7 @@ class DataReaderTests : public ::testing::Test basic_read_apis_check(RETCODE_OK, data_reader_, true); // Check with disposed instance - if (type_->m_isGetKeyDefined) + if (type_->is_compute_key_provided) { EXPECT_EQ(RETCODE_OK, data_writer_->dispose(&data, handle_wrong_)); basic_read_apis_check(RETCODE_OK, data_reader_, true); @@ -1798,8 +1798,8 @@ TEST_F(DataReaderTests, sample_info) data_[0].index(1); data_[1].index(2); - type.get_key(&data_[0], &handles_[0]); - type.get_key(&data_[1], &handles_[1]); + type.compute_key(&data_[0], handles_[0]); + type.compute_key(&data_[1], handles_[1]); } ~TestState() @@ -2103,7 +2103,7 @@ TEST_F(DataReaderTests, check_read_take_iteration) { // calculate key data.index(i); - type_.get_key(&data, &handles[i]); + type_.compute_key(&data, handles[i]); // write the index as message oarraystream out(data.message()); @@ -2229,7 +2229,7 @@ class FailingFooTypeSupport : public FooTypeSupport } bool deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) override { //Convert DATA to pointer of your type @@ -3281,7 +3281,7 @@ TEST_F(DataReaderTests, InstancePolicyAllocationConsistencyNotKeyed) type.register_type(participant); // This test pretends to use topic with no instances, so the following flag is set false. - type.get()->m_isGetKeyDefined = false; + type.get()->is_compute_key_provided = false; Topic* topic = participant->create_topic("footopic", type.get_type_name(), TOPIC_QOS_DEFAULT); ASSERT_NE(topic, nullptr); @@ -3411,7 +3411,7 @@ TEST_F(DataReaderTests, InstancePolicyAllocationConsistencyKeyed) type.register_type(participant); // This test pretends to use topic with instances, so the following flag is set. - type.get()->m_isGetKeyDefined = true; + type.get()->is_compute_key_provided = true; Topic* topic = participant->create_topic("footopic", type.get_type_name(), TOPIC_QOS_DEFAULT); ASSERT_NE(topic, nullptr); @@ -3764,64 +3764,53 @@ class DataRepresentationTestsTypeSupport : public TopicDataType DataRepresentationTestsTypeSupport() : TopicDataType() { - m_typeSize = 4u + sizeof(LoanableType); - setName("LoanableType"); + max_serialized_type_size = 4u + sizeof(LoanableType); + set_name("LoanableType"); } bool serialize( const void* const /*data*/, - eprosima::fastdds::rtps::SerializedPayload_t* /*payload*/) override - { - return true; - } - - bool serialize( - const void* const /*data*/, - eprosima::fastdds::rtps::SerializedPayload_t* /*payload*/, + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* /*payload*/, + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const /*data*/) override - { - return [this]() - { - return m_typeSize; - }; - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return [this]() - { - return m_typeSize; - }; + return max_serialized_type_size; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - eprosima::fastdds::rtps::InstanceHandle_t* /*ihandle*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -3840,13 +3829,6 @@ class DataRepresentationTestsTypeSupport : public TopicDataType return custom_is_plain_with_rep(data_representation_id); } - MOCK_CONST_METHOD0(custom_is_plain, bool()); - - bool is_plain() const override - { - return custom_is_plain(); - } - }; TEST_F(DataReaderTests, data_type_is_plain_data_representation) @@ -3873,7 +3855,6 @@ TEST_F(DataReaderTests, data_type_is_plain_data_representation) qos_xcdr.representation().m_value.push_back(DataRepresentationId_t::XCDR_DATA_REPRESENTATION); /* Expect the "is_plain" method called with default data representation (XCDR1) */ - EXPECT_CALL(*type, custom_is_plain()).Times(0); EXPECT_CALL(*type, custom_is_plain_with_rep(DataRepresentationId_t::XCDR_DATA_REPRESENTATION)).Times( testing::AtLeast(1)).WillRepeatedly(testing::Return(true)); EXPECT_CALL(*type, custom_is_plain_with_rep(DataRepresentationId_t::XCDR2_DATA_REPRESENTATION)).Times(0); @@ -3891,7 +3872,6 @@ TEST_F(DataReaderTests, data_type_is_plain_data_representation) qos_xcdr2.representation().m_value.push_back(DataRepresentationId_t::XCDR2_DATA_REPRESENTATION); /* Expect the "is_plain" method called with XCDR2 data representation */ - EXPECT_CALL(*type, custom_is_plain()).Times(0); EXPECT_CALL(*type, custom_is_plain_with_rep(DataRepresentationId_t::XCDR_DATA_REPRESENTATION)).Times(0); EXPECT_CALL(*type, custom_is_plain_with_rep(DataRepresentationId_t::XCDR2_DATA_REPRESENTATION)).Times( testing::AtLeast(1)).WillRepeatedly(testing::Return(true)); @@ -3906,7 +3886,6 @@ TEST_F(DataReaderTests, data_type_is_plain_data_representation) qos_no_xcdr.representation().m_value.clear(); /* Expect the "is_plain" method called with both data representation */ - EXPECT_CALL(*type, custom_is_plain()).Times(0); EXPECT_CALL(*type, custom_is_plain_with_rep(DataRepresentationId_t::XCDR_DATA_REPRESENTATION)).Times( testing::AtLeast(1)).WillRepeatedly(testing::Return(true)); EXPECT_CALL(*type, custom_is_plain_with_rep(DataRepresentationId_t::XCDR2_DATA_REPRESENTATION)).Times( diff --git a/test/unittest/dds/subscriber/FooBoundedTypeSupport.hpp b/test/unittest/dds/subscriber/FooBoundedTypeSupport.hpp index c9a7f09d679..67de52cd9e7 100644 --- a/test/unittest/dds/subscriber/FooBoundedTypeSupport.hpp +++ b/test/unittest/dds/subscriber/FooBoundedTypeSupport.hpp @@ -34,32 +34,25 @@ class FooBoundedTypeSupport : public TopicDataType FooBoundedTypeSupport() : TopicDataType() { - setName("type"); - m_typeSize = 4u + 4u + 4u + 256u; // encapsulation + index + message len + message data - m_isGetKeyDefined = false; + set_name("type"); + max_serialized_type_size = 4u + 4u + 4u + 256u; // encapsulation + index + message len + message data + is_compute_key_provided = false; } bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - bool serialize( - const void* const data, - fastdds::rtps::SerializedPayload_t* payload, + fastdds::rtps::SerializedPayload_t& payload, DataRepresentationId_t data_representation) override { const type* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fb(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fb(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fb, 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; + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; #if FASTCDR_VERSION_MAJOR > 1 ser.set_encoding_flag( data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? @@ -81,23 +74,19 @@ class FooBoundedTypeSupport : public TopicDataType } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* payload, + fastdds::rtps::SerializedPayload_t& payload, void* data) override { //Convert DATA to pointer of your type type* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fb(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fb(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. eprosima::fastcdr::Cdr deser(fb @@ -109,7 +98,7 @@ class FooBoundedTypeSupport : public TopicDataType // Deserialize encapsulation. deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; try { @@ -124,38 +113,37 @@ class FooBoundedTypeSupport : public TopicDataType return true; } - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const data, DataRepresentationId_t /*data_representation*/) override { - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; } - void* createData() override + void* create_data() override { return static_cast(new type()); } - void deleteData( + void delete_data( void* data) override { type* p_type = static_cast(data); delete p_type; } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*handle*/, + bool /*force_md5*/) override + { + return false; + } + + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*handle*/, + fastdds::rtps::InstanceHandle_t& /*handle*/, bool /*force_md5*/) override { return false; @@ -166,7 +154,8 @@ class FooBoundedTypeSupport : public TopicDataType return true; } - inline bool is_plain() const override + inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t) const override { return false; } diff --git a/test/unittest/dds/subscriber/FooTypeSupport.hpp b/test/unittest/dds/subscriber/FooTypeSupport.hpp index 757ef86b717..d7c401db323 100644 --- a/test/unittest/dds/subscriber/FooTypeSupport.hpp +++ b/test/unittest/dds/subscriber/FooTypeSupport.hpp @@ -32,32 +32,25 @@ class FooTypeSupport : public TopicDataType FooTypeSupport() : TopicDataType() { - setName("FooType"); - m_typeSize = 4u + 4u + 256u; // encapsulation + index + message - m_isGetKeyDefined = true; + set_name("FooType"); + max_serialized_type_size = 4u + 4u + 256u; // encapsulation + index + message + is_compute_key_provided = true; } bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - bool serialize( - const void* const data, - fastdds::rtps::SerializedPayload_t* payload, + fastdds::rtps::SerializedPayload_t& payload, DataRepresentationId_t data_representation) override { const FooType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fb(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fb(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fb, 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; + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; #if FASTCDR_VERSION_MAJOR > 1 ser.set_encoding_flag( data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? @@ -79,23 +72,19 @@ class FooTypeSupport : public TopicDataType } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* payload, + fastdds::rtps::SerializedPayload_t& payload, void* data) override { //Convert DATA to pointer of your type FooType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fb(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fb(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. eprosima::fastcdr::Cdr deser(fb @@ -107,7 +96,7 @@ class FooTypeSupport : public TopicDataType // Deserialize encapsulation. deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; try { @@ -122,37 +111,42 @@ class FooTypeSupport : public TopicDataType return true; } - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return [this] - { - return m_typeSize; - }; + return max_serialized_type_size; } - void* createData() override + void* create_data() override { return static_cast(new FooType()); } - void deleteData( + void delete_data( void* data) override { FooType* p_type = static_cast(data); delete p_type; } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& payload, + fastdds::rtps::InstanceHandle_t& handle, + bool force_md5) override + { + FooType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; + } + + bool compute_key( const void* const data, - fastdds::rtps::InstanceHandle_t* handle, + fastdds::rtps::InstanceHandle_t& handle, bool force_md5) override { const FooType* p_type = static_cast(data); @@ -176,14 +170,14 @@ class FooTypeSupport : public TopicDataType 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_buf[i]; + handle.value[i] = key_buf[i]; } } return true; @@ -194,7 +188,8 @@ class FooTypeSupport : public TopicDataType return true; } - inline bool is_plain() const override + inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t) const override { return true; } diff --git a/test/unittest/dds/subscriber/SubscriberTests.cpp b/test/unittest/dds/subscriber/SubscriberTests.cpp index 15c45cf5fa4..90e37a3fd00 100644 --- a/test/unittest/dds/subscriber/SubscriberTests.cpp +++ b/test/unittest/dds/subscriber/SubscriberTests.cpp @@ -149,61 +149,53 @@ class TopicDataTypeMock : public TopicDataType TopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - setName("footype"); - } - - bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + max_serialized_type_size = 4u; + set_name("footype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - std::function getSerializedSizeProvider( + uint32_t calculate_serialized_size( const void* const /*data*/, DataRepresentationId_t /*data_representation*/) override { - return []()->uint32_t - { - return 0; - }; + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -826,7 +818,7 @@ TEST(SubscriberTests, DeleteContainedEntities) InstanceHandle_t handle_nil = HANDLE_NIL; BarType data; data.index(1); - type.get_key(&data, &handle_nil); + type.compute_key(&data, handle_nil); EXPECT_EQ(RETCODE_OK, data_writer_foo->write(&data, HANDLE_NIL)); // Wait for data to arrive and check OK should be returned diff --git a/test/unittest/dds/topic/DDSSQLFilter/CMakeLists.txt b/test/unittest/dds/topic/DDSSQLFilter/CMakeLists.txt index d03f8daec6d..596650541d0 100644 --- a/test/unittest/dds/topic/DDSSQLFilter/CMakeLists.txt +++ b/test/unittest/dds/topic/DDSSQLFilter/CMakeLists.txt @@ -21,7 +21,6 @@ file(GLOB DDSSQLFILTER_SOURCES file(GLOB DDSSQLFILTER_LIB_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/*.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/SerializedPayload.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp diff --git a/test/unittest/dds/topic/DDSSQLFilter/DDSSQLFilterTests.cpp b/test/unittest/dds/topic/DDSSQLFilter/DDSSQLFilterTests.cpp index a9ea31a13cc..8ce141db95b 100644 --- a/test/unittest/dds/topic/DDSSQLFilter/DDSSQLFilterTests.cpp +++ b/test/unittest/dds/topic/DDSSQLFilter/DDSSQLFilterTests.cpp @@ -679,10 +679,10 @@ class DDSSQLFilterValueGlobalData { static ContentFilterTestTypePubSubType type_support; auto data_ptr = const_cast(&data); - auto data_size = type_support.getSerializedSizeProvider(data_ptr)(); + auto data_size = type_support.calculate_serialized_size(data_ptr, fastdds::dds::DEFAULT_DATA_REPRESENTATION); auto payload = new IContentFilter::SerializedPayload(data_size); values_.emplace_back(payload); - type_support.serialize(data_ptr, payload); + type_support.serialize(data_ptr, *payload, fastdds::dds::DEFAULT_DATA_REPRESENTATION); } void add_char_values( diff --git a/test/unittest/dds/topic/DDSSQLFilter/data_types/ContentFilterTestTypePubSubTypes.cxx b/test/unittest/dds/topic/DDSSQLFilter/data_types/ContentFilterTestTypePubSubTypes.cxx index a44e2598272..99da02c4b96 100644 --- a/test/unittest/dds/topic/DDSSQLFilter/data_types/ContentFilterTestTypePubSubTypes.cxx +++ b/test/unittest/dds/topic/DDSSQLFilter/data_types/ContentFilterTestTypePubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; StructTypePubSubType::StructTypePubSubType() { - setName("StructType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructType::getMaxCdrSerializedSize()); -#else - StructType_max_cdr_typesize; -#endif + set_name("StructType"); + uint32_t type_size = StructType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructType_max_key_cdr_typesize > 16 ? StructType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + 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 (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool StructTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool StructTypePubSubType::deserialize( StructType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool StructTypePubSubType::deserialize( return true; } -std::function StructTypePubSubType::getSerializedSizeProvider( +uint32_t StructTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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::createData() +void* StructTypePubSubType::create_data() { return reinterpret_cast(new StructType()); } -void StructTypePubSubType::deleteData( +void StructTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructTypePubSubType::getKey( +bool StructTypePubSubType::compute_key( + SerializedPayload_t& payload, + 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); + } + + return false; +} + +bool StructTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool StructTypePubSubType::getKey( const StructType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -228,49 +215,42 @@ void StructTypePubSubType::register_type_object_representation() ContentFilterTestTypePubSubType::ContentFilterTestTypePubSubType() { - setName("ContentFilterTestType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ContentFilterTestType::getMaxCdrSerializedSize()); -#else - ContentFilterTestType_max_cdr_typesize; -#endif + set_name("ContentFilterTestType"); + uint32_t type_size = ContentFilterTestType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ContentFilterTestType_max_key_cdr_typesize > 16 ? ContentFilterTestType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ContentFilterTestType_max_key_cdr_typesize > 16 ? ContentFilterTestType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ContentFilterTestTypePubSubType::~ContentFilterTestTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ContentFilterTestTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ContentFilterTestType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -285,16 +265,12 @@ bool ContentFilterTestTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ContentFilterTestTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -303,18 +279,14 @@ bool ContentFilterTestTypePubSubType::deserialize( ContentFilterTestType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -327,52 +299,62 @@ bool ContentFilterTestTypePubSubType::deserialize( return true; } -std::function ContentFilterTestTypePubSubType::getSerializedSizeProvider( +uint32_t ContentFilterTestTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ContentFilterTestTypePubSubType::createData() +void* ContentFilterTestTypePubSubType::create_data() { return reinterpret_cast(new ContentFilterTestType()); } -void ContentFilterTestTypePubSubType::deleteData( +void ContentFilterTestTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ContentFilterTestTypePubSubType::getKey( +bool ContentFilterTestTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ContentFilterTestType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ContentFilterTestTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -380,35 +362,27 @@ bool ContentFilterTestTypePubSubType::getKey( const ContentFilterTestType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ContentFilterTestType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ContentFilterTestType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/topic/DDSSQLFilter/data_types/ContentFilterTestTypePubSubTypes.hpp b/test/unittest/dds/topic/DDSSQLFilter/data_types/ContentFilterTestTypePubSubTypes.hpp index ef6451890ec..fe817ca2f89 100644 --- a/test/unittest/dds/topic/DDSSQLFilter/data_types/ContentFilterTestTypePubSubTypes.hpp +++ b/test/unittest/dds/topic/DDSSQLFilter/data_types/ContentFilterTestTypePubSubTypes.hpp @@ -32,10 +32,10 @@ #include "ContentFilterTestType.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated ContentFilterTestType is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class StructTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class StructTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class StructTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -147,38 +137,30 @@ class ContentFilterTestTypePubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -193,10 +175,6 @@ class ContentFilterTestTypePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -217,8 +195,10 @@ class ContentFilterTestTypePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/topic/TopicTests.cpp b/test/unittest/dds/topic/TopicTests.cpp index faa68b10c87..670d248495a 100644 --- a/test/unittest/dds/topic/TopicTests.cpp +++ b/test/unittest/dds/topic/TopicTests.cpp @@ -68,46 +68,53 @@ class TopicDataTypeMock : public TopicDataType TopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - setName("footype"); + max_serialized_type_size = 4u; + set_name("footype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/) override + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::dds::DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const /*data*/) override + uint32_t calculate_serialized_size( + const void* const /*data*/, + fastdds::dds::DataRepresentationId_t /*data_representation*/) override { - return []()->uint32_t - { - return 0; - }; + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -115,7 +122,7 @@ class TopicDataTypeMock : public TopicDataType private: - using TopicDataType::getSerializedSizeProvider; + using TopicDataType::calculate_serialized_size; using TopicDataType::serialize; }; @@ -361,7 +368,7 @@ TEST(TopicTests, InstancePolicyAllocationConsistencyKeyed) type.register_type(participant); // This test pretends to use topic with instances, so the following flag is set. - type.get()->m_isGetKeyDefined = true; + type.get()->is_compute_key_provided = true; // Next QoS config checks the default qos configuration, // create_topic() should not return nullptr. diff --git a/test/unittest/dds/xtypes/serializers/idl/types/alias_struct/gen/alias_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/alias_struct/gen/alias_structPubSubTypes.cxx index 5957e1d7df1..7efe9e43918 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/alias_struct/gen/alias_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/alias_struct/gen/alias_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; AliasStructPubSubType::AliasStructPubSubType() { - setName("AliasStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AliasStruct::getMaxCdrSerializedSize()); -#else - AliasStruct_max_cdr_typesize; -#endif + set_name("AliasStruct"); + uint32_t type_size = AliasStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AliasStruct_max_key_cdr_typesize > 16 ? AliasStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AliasStruct_max_key_cdr_typesize > 16 ? AliasStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AliasStructPubSubType::~AliasStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AliasStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AliasStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool AliasStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AliasStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool AliasStructPubSubType::deserialize( AliasStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool AliasStructPubSubType::deserialize( return true; } -std::function AliasStructPubSubType::getSerializedSizeProvider( +uint32_t AliasStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* AliasStructPubSubType::createData() +void* AliasStructPubSubType::create_data() { return reinterpret_cast(new AliasStruct()); } -void AliasStructPubSubType::deleteData( +void AliasStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AliasStructPubSubType::getKey( +bool AliasStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AliasStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AliasStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool AliasStructPubSubType::getKey( const AliasStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AliasStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AliasStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/alias_struct/gen/alias_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/alias_struct/gen/alias_structPubSubTypes.hpp index efef4820a40..8a24de83518 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/alias_struct/gen/alias_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/alias_struct/gen/alias_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "alias_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated alias_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER typedef uint32_t MyLong; typedef int16_t MyShort; @@ -59,38 +59,30 @@ class AliasStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -105,10 +97,6 @@ class AliasStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -129,8 +117,10 @@ class AliasStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/array_struct/gen/array_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/array_struct/gen/array_structPubSubTypes.cxx index 21aa3f8ab17..f4e934c5692 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/array_struct/gen/array_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/array_struct/gen/array_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; NestedArrayElementPubSubType::NestedArrayElementPubSubType() { - setName("NestedArrayElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(NestedArrayElement::getMaxCdrSerializedSize()); -#else - NestedArrayElement_max_cdr_typesize; -#endif + set_name("NestedArrayElement"); + uint32_t type_size = NestedArrayElement_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = NestedArrayElement_max_key_cdr_typesize > 16 ? NestedArrayElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = NestedArrayElement_max_key_cdr_typesize > 16 ? NestedArrayElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } NestedArrayElementPubSubType::~NestedArrayElementPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool NestedArrayElementPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const NestedArrayElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool NestedArrayElementPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool NestedArrayElementPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool NestedArrayElementPubSubType::deserialize( NestedArrayElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool NestedArrayElementPubSubType::deserialize( return true; } -std::function NestedArrayElementPubSubType::getSerializedSizeProvider( +uint32_t NestedArrayElementPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* NestedArrayElementPubSubType::createData() +void* NestedArrayElementPubSubType::create_data() { return reinterpret_cast(new NestedArrayElement()); } -void NestedArrayElementPubSubType::deleteData( +void NestedArrayElementPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool NestedArrayElementPubSubType::getKey( +bool NestedArrayElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + NestedArrayElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool NestedArrayElementPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool NestedArrayElementPubSubType::getKey( const NestedArrayElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), NestedArrayElement_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || NestedArrayElement_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void NestedArrayElementPubSubType::register_type_object_representation() ComplexArrayElementPubSubType::ComplexArrayElementPubSubType() { - setName("ComplexArrayElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ComplexArrayElement::getMaxCdrSerializedSize()); -#else - ComplexArrayElement_max_cdr_typesize; -#endif + set_name("ComplexArrayElement"); + uint32_t type_size = ComplexArrayElement_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ComplexArrayElement_max_key_cdr_typesize > 16 ? ComplexArrayElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ComplexArrayElement_max_key_cdr_typesize > 16 ? ComplexArrayElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ComplexArrayElementPubSubType::~ComplexArrayElementPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ComplexArrayElementPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ComplexArrayElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool ComplexArrayElementPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ComplexArrayElementPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool ComplexArrayElementPubSubType::deserialize( ComplexArrayElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool ComplexArrayElementPubSubType::deserialize( return true; } -std::function ComplexArrayElementPubSubType::getSerializedSizeProvider( +uint32_t ComplexArrayElementPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ComplexArrayElementPubSubType::createData() +void* ComplexArrayElementPubSubType::create_data() { return reinterpret_cast(new ComplexArrayElement()); } -void ComplexArrayElementPubSubType::deleteData( +void ComplexArrayElementPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ComplexArrayElementPubSubType::getKey( +bool ComplexArrayElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ComplexArrayElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ComplexArrayElementPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool ComplexArrayElementPubSubType::getKey( const ComplexArrayElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ComplexArrayElement_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ComplexArrayElement_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void ComplexArrayElementPubSubType::register_type_object_representation() ArrayStructPubSubType::ArrayStructPubSubType() { - setName("ArrayStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ArrayStruct::getMaxCdrSerializedSize()); -#else - ArrayStruct_max_cdr_typesize; -#endif + set_name("ArrayStruct"); + uint32_t type_size = ArrayStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ArrayStruct_max_key_cdr_typesize > 16 ? ArrayStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ArrayStruct_max_key_cdr_typesize > 16 ? ArrayStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ArrayStructPubSubType::~ArrayStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ArrayStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ArrayStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool ArrayStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ArrayStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool ArrayStructPubSubType::deserialize( ArrayStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool ArrayStructPubSubType::deserialize( return true; } -std::function ArrayStructPubSubType::getSerializedSizeProvider( +uint32_t ArrayStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ArrayStructPubSubType::createData() +void* ArrayStructPubSubType::create_data() { return reinterpret_cast(new ArrayStruct()); } -void ArrayStructPubSubType::deleteData( +void ArrayStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ArrayStructPubSubType::getKey( +bool ArrayStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ArrayStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ArrayStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool ArrayStructPubSubType::getKey( const ArrayStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ArrayStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ArrayStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/array_struct/gen/array_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/array_struct/gen/array_structPubSubTypes.hpp index 0d0672b8fc1..ea2758b2daa 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/array_struct/gen/array_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/array_struct/gen/array_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "array_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated array_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class NestedArrayElementPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class NestedArrayElementPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class NestedArrayElementPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -145,38 +135,30 @@ class ComplexArrayElementPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -191,10 +173,6 @@ class ComplexArrayElementPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,8 +193,10 @@ class ComplexArrayElementPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -236,38 +216,30 @@ class ArrayStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -282,10 +254,6 @@ class ArrayStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -306,8 +274,10 @@ class ArrayStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/bitmask_struct/gen/bitmask_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/bitmask_struct/gen/bitmask_structPubSubTypes.cxx index a42af45f42c..550e833dd9b 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/bitmask_struct/gen/bitmask_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/bitmask_struct/gen/bitmask_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; BitmaskStructPubSubType::BitmaskStructPubSubType() { - setName("BitmaskStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BitmaskStruct::getMaxCdrSerializedSize()); -#else - BitmaskStruct_max_cdr_typesize; -#endif + set_name("BitmaskStruct"); + uint32_t type_size = BitmaskStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BitmaskStruct_max_key_cdr_typesize > 16 ? BitmaskStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BitmaskStruct_max_key_cdr_typesize > 16 ? BitmaskStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BitmaskStructPubSubType::~BitmaskStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BitmaskStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BitmaskStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool BitmaskStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BitmaskStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool BitmaskStructPubSubType::deserialize( BitmaskStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool BitmaskStructPubSubType::deserialize( return true; } -std::function BitmaskStructPubSubType::getSerializedSizeProvider( +uint32_t BitmaskStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* BitmaskStructPubSubType::createData() +void* BitmaskStructPubSubType::create_data() { return reinterpret_cast(new BitmaskStruct()); } -void BitmaskStructPubSubType::deleteData( +void BitmaskStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BitmaskStructPubSubType::getKey( +bool BitmaskStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BitmaskStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BitmaskStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool BitmaskStructPubSubType::getKey( const BitmaskStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BitmaskStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BitmaskStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/bitmask_struct/gen/bitmask_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/bitmask_struct/gen/bitmask_structPubSubTypes.hpp index df42d2f96aa..3748dcf031e 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/bitmask_struct/gen/bitmask_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/bitmask_struct/gen/bitmask_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "bitmask_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated bitmask_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class BitmaskStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class BitmaskStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class BitmaskStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/bitset_struct/gen/bitset_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/bitset_struct/gen/bitset_structPubSubTypes.cxx index d327fd7adb3..87fc04b94c9 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/bitset_struct/gen/bitset_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/bitset_struct/gen/bitset_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; BitsetStructPubSubType::BitsetStructPubSubType() { - setName("BitsetStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(BitsetStruct::getMaxCdrSerializedSize()); -#else - BitsetStruct_max_cdr_typesize; -#endif + set_name("BitsetStruct"); + uint32_t type_size = BitsetStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = BitsetStruct_max_key_cdr_typesize > 16 ? BitsetStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = BitsetStruct_max_key_cdr_typesize > 16 ? BitsetStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } BitsetStructPubSubType::~BitsetStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool BitsetStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const BitsetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool BitsetStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool BitsetStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool BitsetStructPubSubType::deserialize( BitsetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool BitsetStructPubSubType::deserialize( return true; } -std::function BitsetStructPubSubType::getSerializedSizeProvider( +uint32_t BitsetStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* BitsetStructPubSubType::createData() +void* BitsetStructPubSubType::create_data() { return reinterpret_cast(new BitsetStruct()); } -void BitsetStructPubSubType::deleteData( +void BitsetStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool BitsetStructPubSubType::getKey( +bool BitsetStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + BitsetStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool BitsetStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool BitsetStructPubSubType::getKey( const BitsetStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), BitsetStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || BitsetStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/bitset_struct/gen/bitset_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/bitset_struct/gen/bitset_structPubSubTypes.hpp index 299306c4338..540f233b50e 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/bitset_struct/gen/bitset_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/bitset_struct/gen/bitset_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "bitset_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated bitset_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class BitsetStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class BitsetStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class BitsetStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/enum_struct/gen/enum_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/enum_struct/gen/enum_structPubSubTypes.cxx index e6d63cec8b4..5650af14317 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/enum_struct/gen/enum_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/enum_struct/gen/enum_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; EnumStructPubSubType::EnumStructPubSubType() { - setName("EnumStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(EnumStruct::getMaxCdrSerializedSize()); -#else - EnumStruct_max_cdr_typesize; -#endif + set_name("EnumStruct"); + uint32_t type_size = EnumStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = EnumStruct_max_key_cdr_typesize > 16 ? EnumStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = EnumStruct_max_key_cdr_typesize > 16 ? EnumStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } EnumStructPubSubType::~EnumStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool EnumStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const EnumStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool EnumStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool EnumStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool EnumStructPubSubType::deserialize( EnumStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool EnumStructPubSubType::deserialize( return true; } -std::function EnumStructPubSubType::getSerializedSizeProvider( +uint32_t EnumStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* EnumStructPubSubType::createData() +void* EnumStructPubSubType::create_data() { return reinterpret_cast(new EnumStruct()); } -void EnumStructPubSubType::deleteData( +void EnumStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool EnumStructPubSubType::getKey( +bool EnumStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + EnumStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool EnumStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool EnumStructPubSubType::getKey( const EnumStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), EnumStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || EnumStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/enum_struct/gen/enum_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/enum_struct/gen/enum_structPubSubTypes.hpp index 4a0e3122b01..d8e06efaedd 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/enum_struct/gen/enum_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/enum_struct/gen/enum_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "enum_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated enum_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class EnumStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class EnumStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class EnumStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/extensibility_struct/gen/extensibility_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/extensibility_struct/gen/extensibility_structPubSubTypes.cxx index 87070348864..da3e73436c0 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/extensibility_struct/gen/extensibility_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/extensibility_struct/gen/extensibility_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; FinalStructPubSubType::FinalStructPubSubType() { - setName("FinalStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FinalStruct::getMaxCdrSerializedSize()); -#else - FinalStruct_max_cdr_typesize; -#endif + set_name("FinalStruct"); + uint32_t type_size = FinalStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FinalStruct_max_key_cdr_typesize > 16 ? FinalStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FinalStruct_max_key_cdr_typesize > 16 ? FinalStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } FinalStructPubSubType::~FinalStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool FinalStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const FinalStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PLAIN_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool FinalStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool FinalStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool FinalStructPubSubType::deserialize( FinalStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool FinalStructPubSubType::deserialize( return true; } -std::function FinalStructPubSubType::getSerializedSizeProvider( +uint32_t FinalStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FinalStructPubSubType::createData() + 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* FinalStructPubSubType::create_data() { return reinterpret_cast(new FinalStruct()); } -void FinalStructPubSubType::deleteData( +void FinalStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool FinalStructPubSubType::getKey( +bool FinalStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FinalStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FinalStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool FinalStructPubSubType::getKey( const FinalStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), FinalStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || FinalStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void FinalStructPubSubType::register_type_object_representation() MutableStructPubSubType::MutableStructPubSubType() { - setName("MutableStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MutableStruct::getMaxCdrSerializedSize()); -#else - MutableStruct_max_cdr_typesize; -#endif + set_name("MutableStruct"); + uint32_t type_size = MutableStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MutableStruct_max_key_cdr_typesize > 16 ? MutableStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MutableStruct_max_key_cdr_typesize > 16 ? MutableStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MutableStructPubSubType::~MutableStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MutableStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MutableStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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::PL_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool MutableStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MutableStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool MutableStructPubSubType::deserialize( MutableStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool MutableStructPubSubType::deserialize( return true; } -std::function MutableStructPubSubType::getSerializedSizeProvider( +uint32_t MutableStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MutableStructPubSubType::createData() + 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* MutableStructPubSubType::create_data() { return reinterpret_cast(new MutableStruct()); } -void MutableStructPubSubType::deleteData( +void MutableStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MutableStructPubSubType::getKey( +bool MutableStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MutableStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MutableStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool MutableStructPubSubType::getKey( const MutableStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MutableStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MutableStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void MutableStructPubSubType::register_type_object_representation() AppendableStructPubSubType::AppendableStructPubSubType() { - setName("AppendableStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AppendableStruct::getMaxCdrSerializedSize()); -#else - AppendableStruct_max_cdr_typesize; -#endif + set_name("AppendableStruct"); + uint32_t type_size = AppendableStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AppendableStruct_max_key_cdr_typesize > 16 ? AppendableStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AppendableStruct_max_key_cdr_typesize > 16 ? AppendableStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AppendableStructPubSubType::~AppendableStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AppendableStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AppendableStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool AppendableStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AppendableStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool AppendableStructPubSubType::deserialize( AppendableStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool AppendableStructPubSubType::deserialize( return true; } -std::function AppendableStructPubSubType::getSerializedSizeProvider( +uint32_t AppendableStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AppendableStructPubSubType::createData() + 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* AppendableStructPubSubType::create_data() { return reinterpret_cast(new AppendableStruct()); } -void AppendableStructPubSubType::deleteData( +void AppendableStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AppendableStructPubSubType::getKey( +bool AppendableStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AppendableStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AppendableStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool AppendableStructPubSubType::getKey( const AppendableStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AppendableStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AppendableStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void AppendableStructPubSubType::register_type_object_representation() ExtensibilityStructPubSubType::ExtensibilityStructPubSubType() { - setName("ExtensibilityStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ExtensibilityStruct::getMaxCdrSerializedSize()); -#else - ExtensibilityStruct_max_cdr_typesize; -#endif + set_name("ExtensibilityStruct"); + uint32_t type_size = ExtensibilityStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ExtensibilityStruct_max_key_cdr_typesize > 16 ? ExtensibilityStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ExtensibilityStruct_max_key_cdr_typesize > 16 ? ExtensibilityStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ExtensibilityStructPubSubType::~ExtensibilityStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ExtensibilityStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ExtensibilityStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool ExtensibilityStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ExtensibilityStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool ExtensibilityStructPubSubType::deserialize( ExtensibilityStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool ExtensibilityStructPubSubType::deserialize( return true; } -std::function ExtensibilityStructPubSubType::getSerializedSizeProvider( +uint32_t ExtensibilityStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ExtensibilityStructPubSubType::createData() + 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* ExtensibilityStructPubSubType::create_data() { return reinterpret_cast(new ExtensibilityStruct()); } -void ExtensibilityStructPubSubType::deleteData( +void ExtensibilityStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ExtensibilityStructPubSubType::getKey( +bool ExtensibilityStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ExtensibilityStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ExtensibilityStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool ExtensibilityStructPubSubType::getKey( const ExtensibilityStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ExtensibilityStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ExtensibilityStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/extensibility_struct/gen/extensibility_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/extensibility_struct/gen/extensibility_structPubSubTypes.hpp index 28ad65cb910..0935ace0331 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/extensibility_struct/gen/extensibility_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/extensibility_struct/gen/extensibility_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "extensibility_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated extensibility_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER #ifndef SWIG @@ -87,38 +87,30 @@ class FinalStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -133,10 +125,6 @@ class FinalStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_xcdrv1_impl(); - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -163,11 +151,12 @@ class FinalStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; + + static constexpr bool is_plain_xcdrv1_impl() { return 1ULL == @@ -200,38 +189,30 @@ class MutableStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -246,10 +227,6 @@ class MutableStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -270,8 +247,10 @@ class MutableStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -291,38 +270,30 @@ class AppendableStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -337,10 +308,6 @@ class AppendableStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -361,8 +328,10 @@ class AppendableStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -382,38 +351,30 @@ class ExtensibilityStructPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -428,10 +389,6 @@ class ExtensibilityStructPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -452,8 +409,10 @@ class ExtensibilityStructPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/key_struct/gen/key_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/key_struct/gen/key_structPubSubTypes.cxx index 4a48941b222..9a122e68649 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/key_struct/gen/key_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/key_struct/gen/key_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; ImportantStructPubSubType::ImportantStructPubSubType() { - setName("ImportantStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ImportantStruct::getMaxCdrSerializedSize()); -#else - ImportantStruct_max_cdr_typesize; -#endif + set_name("ImportantStruct"); + uint32_t type_size = ImportantStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = ImportantStruct_max_key_cdr_typesize > 16 ? ImportantStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = ImportantStruct_max_key_cdr_typesize > 16 ? ImportantStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ImportantStructPubSubType::~ImportantStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ImportantStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ImportantStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool ImportantStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ImportantStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool ImportantStructPubSubType::deserialize( ImportantStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool ImportantStructPubSubType::deserialize( return true; } -std::function ImportantStructPubSubType::getSerializedSizeProvider( +uint32_t ImportantStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ImportantStructPubSubType::createData() +void* ImportantStructPubSubType::create_data() { return reinterpret_cast(new ImportantStruct()); } -void ImportantStructPubSubType::deleteData( +void ImportantStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ImportantStructPubSubType::getKey( +bool ImportantStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ImportantStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ImportantStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool ImportantStructPubSubType::getKey( const ImportantStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ImportantStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ImportantStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void ImportantStructPubSubType::register_type_object_representation() KeyStructPubSubType::KeyStructPubSubType() { - setName("KeyStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyStruct::getMaxCdrSerializedSize()); -#else - KeyStruct_max_cdr_typesize; -#endif + set_name("KeyStruct"); + uint32_t type_size = KeyStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = KeyStruct_max_key_cdr_typesize > 16 ? KeyStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = KeyStruct_max_key_cdr_typesize > 16 ? KeyStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } KeyStructPubSubType::~KeyStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool KeyStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const KeyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool KeyStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool KeyStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool KeyStructPubSubType::deserialize( KeyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool KeyStructPubSubType::deserialize( return true; } -std::function KeyStructPubSubType::getSerializedSizeProvider( +uint32_t KeyStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* KeyStructPubSubType::createData() +void* KeyStructPubSubType::create_data() { return reinterpret_cast(new KeyStruct()); } -void KeyStructPubSubType::deleteData( +void KeyStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool KeyStructPubSubType::getKey( +bool KeyStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + KeyStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool KeyStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool KeyStructPubSubType::getKey( const KeyStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), KeyStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/key_struct/gen/key_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/key_struct/gen/key_structPubSubTypes.hpp index bb3d4678554..e57f9d039d9 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/key_struct/gen/key_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/key_struct/gen/key_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "key_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated key_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class ImportantStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class ImportantStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class ImportantStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -145,38 +135,30 @@ class KeyStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -191,10 +173,6 @@ class KeyStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,8 +193,10 @@ class KeyStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/map_struct/gen/map_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/map_struct/gen/map_structPubSubTypes.cxx index 8c30463bdcc..45faab89249 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/map_struct/gen/map_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/map_struct/gen/map_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; ValueStructPubSubType::ValueStructPubSubType() { - setName("ValueStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ValueStruct::getMaxCdrSerializedSize()); -#else - ValueStruct_max_cdr_typesize; -#endif + set_name("ValueStruct"); + uint32_t type_size = ValueStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ValueStruct_max_key_cdr_typesize > 16 ? ValueStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ValueStruct_max_key_cdr_typesize > 16 ? ValueStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ValueStructPubSubType::~ValueStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ValueStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ValueStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool ValueStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ValueStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool ValueStructPubSubType::deserialize( ValueStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool ValueStructPubSubType::deserialize( return true; } -std::function ValueStructPubSubType::getSerializedSizeProvider( +uint32_t ValueStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ValueStructPubSubType::createData() +void* ValueStructPubSubType::create_data() { return reinterpret_cast(new ValueStruct()); } -void ValueStructPubSubType::deleteData( +void ValueStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ValueStructPubSubType::getKey( +bool ValueStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ValueStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ValueStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool ValueStructPubSubType::getKey( const ValueStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ValueStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ValueStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void ValueStructPubSubType::register_type_object_representation() MapStructPubSubType::MapStructPubSubType() { - setName("MapStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MapStruct::getMaxCdrSerializedSize()); -#else - MapStruct_max_cdr_typesize; -#endif + set_name("MapStruct"); + uint32_t type_size = MapStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MapStruct_max_key_cdr_typesize > 16 ? MapStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MapStruct_max_key_cdr_typesize > 16 ? MapStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } MapStructPubSubType::~MapStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool MapStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const MapStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool MapStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool MapStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool MapStructPubSubType::deserialize( MapStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool MapStructPubSubType::deserialize( return true; } -std::function MapStructPubSubType::getSerializedSizeProvider( +uint32_t MapStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* MapStructPubSubType::createData() +void* MapStructPubSubType::create_data() { return reinterpret_cast(new MapStruct()); } -void MapStructPubSubType::deleteData( +void MapStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool MapStructPubSubType::getKey( +bool MapStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MapStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MapStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool MapStructPubSubType::getKey( const MapStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), MapStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MapStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/map_struct/gen/map_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/map_struct/gen/map_structPubSubTypes.hpp index 6cffc72f9e0..0afc151f82a 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/map_struct/gen/map_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/map_struct/gen/map_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "map_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated map_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class ValueStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class ValueStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class ValueStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -145,38 +135,30 @@ class MapStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -191,10 +173,6 @@ class MapStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,8 +193,10 @@ class MapStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/primitives_struct/gen/primitives_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/primitives_struct/gen/primitives_structPubSubTypes.cxx index 3434ba975ca..5974d5412cb 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/primitives_struct/gen/primitives_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/primitives_struct/gen/primitives_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; PrimitivesStructPubSubType::PrimitivesStructPubSubType() { - setName("PrimitivesStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(PrimitivesStruct::getMaxCdrSerializedSize()); -#else - PrimitivesStruct_max_cdr_typesize; -#endif + set_name("PrimitivesStruct"); + uint32_t type_size = PrimitivesStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = PrimitivesStruct_max_key_cdr_typesize > 16 ? PrimitivesStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = PrimitivesStruct_max_key_cdr_typesize > 16 ? PrimitivesStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PrimitivesStructPubSubType::~PrimitivesStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PrimitivesStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PrimitivesStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool PrimitivesStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PrimitivesStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool PrimitivesStructPubSubType::deserialize( PrimitivesStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool PrimitivesStructPubSubType::deserialize( return true; } -std::function PrimitivesStructPubSubType::getSerializedSizeProvider( +uint32_t PrimitivesStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* PrimitivesStructPubSubType::createData() +void* PrimitivesStructPubSubType::create_data() { return reinterpret_cast(new PrimitivesStruct()); } -void PrimitivesStructPubSubType::deleteData( +void PrimitivesStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool PrimitivesStructPubSubType::getKey( +bool PrimitivesStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + PrimitivesStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool PrimitivesStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool PrimitivesStructPubSubType::getKey( const PrimitivesStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), PrimitivesStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || PrimitivesStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/primitives_struct/gen/primitives_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/primitives_struct/gen/primitives_structPubSubTypes.hpp index afcc3758609..660b9e10916 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/primitives_struct/gen/primitives_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/primitives_struct/gen/primitives_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "primitives_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated primitives_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class PrimitivesStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class PrimitivesStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class PrimitivesStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/sequence_struct/gen/sequence_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/sequence_struct/gen/sequence_structPubSubTypes.cxx index 406a1041ea5..d18b62727ca 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/sequence_struct/gen/sequence_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/sequence_struct/gen/sequence_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; NestedSequenceElementPubSubType::NestedSequenceElementPubSubType() { - setName("NestedSequenceElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(NestedSequenceElement::getMaxCdrSerializedSize()); -#else - NestedSequenceElement_max_cdr_typesize; -#endif + set_name("NestedSequenceElement"); + uint32_t type_size = NestedSequenceElement_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = NestedSequenceElement_max_key_cdr_typesize > 16 ? NestedSequenceElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = NestedSequenceElement_max_key_cdr_typesize > 16 ? NestedSequenceElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } NestedSequenceElementPubSubType::~NestedSequenceElementPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool NestedSequenceElementPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const NestedSequenceElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool NestedSequenceElementPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool NestedSequenceElementPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool NestedSequenceElementPubSubType::deserialize( NestedSequenceElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool NestedSequenceElementPubSubType::deserialize( return true; } -std::function NestedSequenceElementPubSubType::getSerializedSizeProvider( +uint32_t NestedSequenceElementPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* NestedSequenceElementPubSubType::createData() +void* NestedSequenceElementPubSubType::create_data() { return reinterpret_cast(new NestedSequenceElement()); } -void NestedSequenceElementPubSubType::deleteData( +void NestedSequenceElementPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool NestedSequenceElementPubSubType::getKey( +bool NestedSequenceElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + NestedSequenceElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool NestedSequenceElementPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool NestedSequenceElementPubSubType::getKey( const NestedSequenceElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), NestedSequenceElement_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || NestedSequenceElement_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void NestedSequenceElementPubSubType::register_type_object_representation() ComplexSequenceElementPubSubType::ComplexSequenceElementPubSubType() { - setName("ComplexSequenceElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ComplexSequenceElement::getMaxCdrSerializedSize()); -#else - ComplexSequenceElement_max_cdr_typesize; -#endif + set_name("ComplexSequenceElement"); + uint32_t type_size = ComplexSequenceElement_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ComplexSequenceElement_max_key_cdr_typesize > 16 ? ComplexSequenceElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ComplexSequenceElement_max_key_cdr_typesize > 16 ? ComplexSequenceElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ComplexSequenceElementPubSubType::~ComplexSequenceElementPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ComplexSequenceElementPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ComplexSequenceElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool ComplexSequenceElementPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ComplexSequenceElementPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool ComplexSequenceElementPubSubType::deserialize( ComplexSequenceElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool ComplexSequenceElementPubSubType::deserialize( return true; } -std::function ComplexSequenceElementPubSubType::getSerializedSizeProvider( +uint32_t ComplexSequenceElementPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ComplexSequenceElementPubSubType::createData() +void* ComplexSequenceElementPubSubType::create_data() { return reinterpret_cast(new ComplexSequenceElement()); } -void ComplexSequenceElementPubSubType::deleteData( +void ComplexSequenceElementPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ComplexSequenceElementPubSubType::getKey( +bool ComplexSequenceElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ComplexSequenceElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ComplexSequenceElementPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool ComplexSequenceElementPubSubType::getKey( const ComplexSequenceElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ComplexSequenceElement_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ComplexSequenceElement_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void ComplexSequenceElementPubSubType::register_type_object_representation() SequenceStructPubSubType::SequenceStructPubSubType() { - setName("SequenceStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SequenceStruct::getMaxCdrSerializedSize()); -#else - SequenceStruct_max_cdr_typesize; -#endif + set_name("SequenceStruct"); + uint32_t type_size = SequenceStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SequenceStruct_max_key_cdr_typesize > 16 ? SequenceStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SequenceStruct_max_key_cdr_typesize > 16 ? SequenceStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } SequenceStructPubSubType::~SequenceStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool SequenceStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const SequenceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool SequenceStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool SequenceStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool SequenceStructPubSubType::deserialize( SequenceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool SequenceStructPubSubType::deserialize( return true; } -std::function SequenceStructPubSubType::getSerializedSizeProvider( +uint32_t SequenceStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* SequenceStructPubSubType::createData() +void* SequenceStructPubSubType::create_data() { return reinterpret_cast(new SequenceStruct()); } -void SequenceStructPubSubType::deleteData( +void SequenceStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool SequenceStructPubSubType::getKey( +bool SequenceStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SequenceStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SequenceStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool SequenceStructPubSubType::getKey( const SequenceStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), SequenceStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || SequenceStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/sequence_struct/gen/sequence_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/sequence_struct/gen/sequence_structPubSubTypes.hpp index d0c2498530d..7b1156b7fe1 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/sequence_struct/gen/sequence_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/sequence_struct/gen/sequence_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "sequence_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated sequence_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class NestedSequenceElementPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class NestedSequenceElementPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class NestedSequenceElementPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -145,38 +135,30 @@ class ComplexSequenceElementPubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -191,10 +173,6 @@ class ComplexSequenceElementPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,8 +193,10 @@ class ComplexSequenceElementPubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -236,38 +216,30 @@ class SequenceStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -282,10 +254,6 @@ class SequenceStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -306,8 +274,10 @@ class SequenceStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/string_struct/gen/string_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/string_struct/gen/string_structPubSubTypes.cxx index 68f1132a3dc..a14a11b75ab 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/string_struct/gen/string_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/string_struct/gen/string_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; StringStructPubSubType::StringStructPubSubType() { - setName("StringStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StringStruct::getMaxCdrSerializedSize()); -#else - StringStruct_max_cdr_typesize; -#endif + set_name("StringStruct"); + uint32_t type_size = StringStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StringStruct_max_key_cdr_typesize > 16 ? StringStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StringStruct_max_key_cdr_typesize > 16 ? StringStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StringStructPubSubType::~StringStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StringStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool StringStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StringStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool StringStructPubSubType::deserialize( StringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool StringStructPubSubType::deserialize( return true; } -std::function StringStructPubSubType::getSerializedSizeProvider( +uint32_t StringStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* StringStructPubSubType::createData() +void* StringStructPubSubType::create_data() { return reinterpret_cast(new StringStruct()); } -void StringStructPubSubType::deleteData( +void StringStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StringStructPubSubType::getKey( +bool StringStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StringStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StringStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool StringStructPubSubType::getKey( const StringStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StringStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StringStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/string_struct/gen/string_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/string_struct/gen/string_structPubSubTypes.hpp index e8e375b8b10..f65d86f4c42 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/string_struct/gen/string_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/string_struct/gen/string_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "string_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated string_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class StringStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class StringStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class StringStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/struct_struct/gen/struct_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/struct_struct/gen/struct_structPubSubTypes.cxx index 90e507519ec..7bbafa8f696 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/struct_struct/gen/struct_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/struct_struct/gen/struct_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; GrandparentStructPubSubType::GrandparentStructPubSubType() { - setName("GrandparentStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(GrandparentStruct::getMaxCdrSerializedSize()); -#else - GrandparentStruct_max_cdr_typesize; -#endif + set_name("GrandparentStruct"); + uint32_t type_size = GrandparentStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = GrandparentStruct_max_key_cdr_typesize > 16 ? GrandparentStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = GrandparentStruct_max_key_cdr_typesize > 16 ? GrandparentStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } GrandparentStructPubSubType::~GrandparentStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool GrandparentStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const GrandparentStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool GrandparentStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool GrandparentStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool GrandparentStructPubSubType::deserialize( GrandparentStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool GrandparentStructPubSubType::deserialize( return true; } -std::function GrandparentStructPubSubType::getSerializedSizeProvider( +uint32_t GrandparentStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* GrandparentStructPubSubType::createData() + 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* GrandparentStructPubSubType::create_data() { return reinterpret_cast(new GrandparentStruct()); } -void GrandparentStructPubSubType::deleteData( +void GrandparentStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool GrandparentStructPubSubType::getKey( +bool GrandparentStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + GrandparentStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool GrandparentStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool GrandparentStructPubSubType::getKey( const GrandparentStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), GrandparentStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || GrandparentStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -226,49 +213,42 @@ void GrandparentStructPubSubType::register_type_object_representation() ParentStructPubSubType::ParentStructPubSubType() { - setName("ParentStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ParentStruct::getMaxCdrSerializedSize()); -#else - ParentStruct_max_cdr_typesize; -#endif + set_name("ParentStruct"); + uint32_t type_size = ParentStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ParentStruct_max_key_cdr_typesize > 16 ? ParentStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ParentStruct_max_key_cdr_typesize > 16 ? ParentStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ParentStructPubSubType::~ParentStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ParentStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ParentStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -283,16 +263,12 @@ bool ParentStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ParentStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -301,18 +277,14 @@ bool ParentStructPubSubType::deserialize( ParentStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -325,52 +297,62 @@ bool ParentStructPubSubType::deserialize( return true; } -std::function ParentStructPubSubType::getSerializedSizeProvider( +uint32_t ParentStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ParentStructPubSubType::createData() + 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* ParentStructPubSubType::create_data() { return reinterpret_cast(new ParentStruct()); } -void ParentStructPubSubType::deleteData( +void ParentStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ParentStructPubSubType::getKey( +bool ParentStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ParentStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ParentStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -378,35 +360,27 @@ bool ParentStructPubSubType::getKey( const ParentStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ParentStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ParentStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -419,49 +393,42 @@ void ParentStructPubSubType::register_type_object_representation() NestedStructElementPubSubType::NestedStructElementPubSubType() { - setName("NestedStructElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(NestedStructElement::getMaxCdrSerializedSize()); -#else - NestedStructElement_max_cdr_typesize; -#endif + set_name("NestedStructElement"); + uint32_t type_size = NestedStructElement_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = NestedStructElement_max_key_cdr_typesize > 16 ? NestedStructElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = NestedStructElement_max_key_cdr_typesize > 16 ? NestedStructElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } NestedStructElementPubSubType::~NestedStructElementPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool NestedStructElementPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const NestedStructElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -476,16 +443,12 @@ bool NestedStructElementPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool NestedStructElementPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -494,18 +457,14 @@ bool NestedStructElementPubSubType::deserialize( NestedStructElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -518,52 +477,62 @@ bool NestedStructElementPubSubType::deserialize( return true; } -std::function NestedStructElementPubSubType::getSerializedSizeProvider( +uint32_t NestedStructElementPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* NestedStructElementPubSubType::createData() + 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* NestedStructElementPubSubType::create_data() { return reinterpret_cast(new NestedStructElement()); } -void NestedStructElementPubSubType::deleteData( +void NestedStructElementPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool NestedStructElementPubSubType::getKey( +bool NestedStructElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + NestedStructElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool NestedStructElementPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -571,35 +540,27 @@ bool NestedStructElementPubSubType::getKey( const NestedStructElement* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), NestedStructElement_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || NestedStructElement_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -612,49 +573,42 @@ void NestedStructElementPubSubType::register_type_object_representation() StructStructPubSubType::StructStructPubSubType() { - setName("StructStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructStruct::getMaxCdrSerializedSize()); -#else - StructStruct_max_cdr_typesize; -#endif + set_name("StructStruct"); + uint32_t type_size = StructStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = StructStruct_max_key_cdr_typesize > 16 ? StructStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = StructStruct_max_key_cdr_typesize > 16 ? StructStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } StructStructPubSubType::~StructStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool StructStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const StructStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -669,16 +623,12 @@ bool StructStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool StructStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -687,18 +637,14 @@ bool StructStructPubSubType::deserialize( StructStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -711,52 +657,62 @@ bool StructStructPubSubType::deserialize( return true; } -std::function StructStructPubSubType::getSerializedSizeProvider( +uint32_t StructStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* StructStructPubSubType::createData() + 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* StructStructPubSubType::create_data() { return reinterpret_cast(new StructStruct()); } -void StructStructPubSubType::deleteData( +void StructStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool StructStructPubSubType::getKey( +bool StructStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + StructStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool StructStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -764,35 +720,27 @@ bool StructStructPubSubType::getKey( const StructStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), StructStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || StructStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/struct_struct/gen/struct_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/struct_struct/gen/struct_structPubSubTypes.hpp index 5a87fd6aa30..23357a10840 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/struct_struct/gen/struct_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/struct_struct/gen/struct_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "struct_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated struct_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class GrandparentStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class GrandparentStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class GrandparentStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -145,38 +135,30 @@ class ParentStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -191,10 +173,6 @@ class ParentStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,8 +193,10 @@ class ParentStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -236,38 +216,30 @@ class NestedStructElementPubSubType : public eprosima::fastdds::dds::TopicDataTy eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -282,10 +254,6 @@ class NestedStructElementPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -306,8 +274,10 @@ class NestedStructElementPubSubType : public eprosima::fastdds::dds::TopicDataTy #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -327,38 +297,30 @@ class StructStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -373,10 +335,6 @@ class StructStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -397,8 +355,10 @@ class StructStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/union_struct/gen/union_structPubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/idl/types/union_struct/gen/union_structPubSubTypes.cxx index 22ad76ec79b..f48bdf4ced4 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/union_struct/gen/union_structPubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/idl/types/union_struct/gen/union_structPubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; UnionStructPubSubType::UnionStructPubSubType() { - setName("UnionStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(UnionStruct::getMaxCdrSerializedSize()); -#else - UnionStruct_max_cdr_typesize; -#endif + set_name("UnionStruct"); + uint32_t type_size = UnionStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = UnionStruct_max_key_cdr_typesize > 16 ? UnionStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = UnionStruct_max_key_cdr_typesize > 16 ? UnionStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } UnionStructPubSubType::~UnionStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool UnionStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const UnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool UnionStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool UnionStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool UnionStructPubSubType::deserialize( UnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool UnionStructPubSubType::deserialize( return true; } -std::function UnionStructPubSubType::getSerializedSizeProvider( +uint32_t UnionStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* UnionStructPubSubType::createData() +void* UnionStructPubSubType::create_data() { return reinterpret_cast(new UnionStruct()); } -void UnionStructPubSubType::deleteData( +void UnionStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool UnionStructPubSubType::getKey( +bool UnionStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + UnionStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool UnionStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool UnionStructPubSubType::getKey( const UnionStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), UnionStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || UnionStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/idl/types/union_struct/gen/union_structPubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/idl/types/union_struct/gen/union_structPubSubTypes.hpp index bbd1b9e3986..2e5e999e658 100644 --- a/test/unittest/dds/xtypes/serializers/idl/types/union_struct/gen/union_structPubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/idl/types/union_struct/gen/union_structPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "union_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated union_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class UnionStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class UnionStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class UnionStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/gen/ComprehensiveTypePubSubTypes.cxx b/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/gen/ComprehensiveTypePubSubTypes.cxx index fdc299c75e4..94f79a4b011 100644 --- a/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/gen/ComprehensiveTypePubSubTypes.cxx +++ b/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/gen/ComprehensiveTypePubSubTypes.cxx @@ -33,49 +33,42 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; PrimitivesStructPubSubType::PrimitivesStructPubSubType() { - setName("PrimitivesStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(PrimitivesStruct::getMaxCdrSerializedSize()); -#else - PrimitivesStruct_max_cdr_typesize; -#endif + set_name("PrimitivesStruct"); + uint32_t type_size = PrimitivesStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = PrimitivesStruct_max_key_cdr_typesize > 16 ? PrimitivesStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = PrimitivesStruct_max_key_cdr_typesize > 16 ? PrimitivesStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } PrimitivesStructPubSubType::~PrimitivesStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool PrimitivesStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const PrimitivesStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool PrimitivesStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool PrimitivesStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool PrimitivesStructPubSubType::deserialize( PrimitivesStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool PrimitivesStructPubSubType::deserialize( return true; } -std::function PrimitivesStructPubSubType::getSerializedSizeProvider( +uint32_t PrimitivesStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* PrimitivesStructPubSubType::createData() +void* PrimitivesStructPubSubType::create_data() { return reinterpret_cast(new PrimitivesStruct()); } -void PrimitivesStructPubSubType::deleteData( +void PrimitivesStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool PrimitivesStructPubSubType::getKey( +bool PrimitivesStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + PrimitivesStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool PrimitivesStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,27 @@ bool PrimitivesStructPubSubType::getKey( const PrimitivesStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), PrimitivesStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || PrimitivesStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -235,49 +222,42 @@ void PrimitivesStructPubSubType::register_type_object_representation() AllStructPubSubType::AllStructPubSubType() { - setName("AllStruct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AllStruct::getMaxCdrSerializedSize()); -#else - AllStruct_max_cdr_typesize; -#endif + set_name("AllStruct"); + uint32_t type_size = AllStruct_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AllStruct_max_key_cdr_typesize > 16 ? AllStruct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AllStruct_max_key_cdr_typesize > 16 ? AllStruct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } AllStructPubSubType::~AllStructPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool AllStructPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const AllStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -292,16 +272,12 @@ bool AllStructPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool AllStructPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -310,18 +286,14 @@ bool AllStructPubSubType::deserialize( AllStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -334,52 +306,62 @@ bool AllStructPubSubType::deserialize( return true; } -std::function AllStructPubSubType::getSerializedSizeProvider( +uint32_t AllStructPubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* AllStructPubSubType::createData() +void* AllStructPubSubType::create_data() { return reinterpret_cast(new AllStruct()); } -void AllStructPubSubType::deleteData( +void AllStructPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool AllStructPubSubType::getKey( +bool AllStructPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AllStruct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AllStructPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -387,35 +369,27 @@ bool AllStructPubSubType::getKey( const AllStruct* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), AllStruct_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || AllStruct_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; @@ -428,49 +402,42 @@ void AllStructPubSubType::register_type_object_representation() ComprehensiveTypePubSubType::ComprehensiveTypePubSubType() { - setName("ComprehensiveType"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ComprehensiveType::getMaxCdrSerializedSize()); -#else - ComprehensiveType_max_cdr_typesize; -#endif + set_name("ComprehensiveType"); + uint32_t type_size = ComprehensiveType_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ComprehensiveType_max_key_cdr_typesize > 16 ? ComprehensiveType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ComprehensiveType_max_key_cdr_typesize > 16 ? ComprehensiveType_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } ComprehensiveTypePubSubType::~ComprehensiveTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool ComprehensiveTypePubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const ComprehensiveType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + 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); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -485,16 +452,12 @@ bool ComprehensiveTypePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool ComprehensiveTypePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -503,18 +466,14 @@ bool ComprehensiveTypePubSubType::deserialize( ComprehensiveType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + 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; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -527,52 +486,62 @@ bool ComprehensiveTypePubSubType::deserialize( return true; } -std::function ComprehensiveTypePubSubType::getSerializedSizeProvider( +uint32_t ComprehensiveTypePubSubType::calculate_serialized_size( const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + 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* ComprehensiveTypePubSubType::createData() +void* ComprehensiveTypePubSubType::create_data() { return reinterpret_cast(new ComprehensiveType()); } -void ComprehensiveTypePubSubType::deleteData( +void ComprehensiveTypePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool ComprehensiveTypePubSubType::getKey( +bool ComprehensiveTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ComprehensiveType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ComprehensiveTypePubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -580,35 +549,27 @@ bool ComprehensiveTypePubSubType::getKey( const ComprehensiveType* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), ComprehensiveType_max_key_cdr_typesize); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ComprehensiveType_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + 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] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/gen/ComprehensiveTypePubSubTypes.hpp b/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/gen/ComprehensiveTypePubSubTypes.hpp index c538c5d95f5..984eaf6935c 100644 --- a/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/gen/ComprehensiveTypePubSubTypes.hpp +++ b/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/gen/ComprehensiveTypePubSubTypes.hpp @@ -32,10 +32,10 @@ #include "ComprehensiveType.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated ComprehensiveType is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class PrimitivesStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class PrimitivesStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -124,8 +112,10 @@ class PrimitivesStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -154,38 +144,30 @@ class AllStructPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -200,10 +182,6 @@ class AllStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -224,8 +202,10 @@ class AllStructPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; @@ -245,38 +225,30 @@ class ComprehensiveTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + 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, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + 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, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -291,10 +263,6 @@ class ComprehensiveTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -315,8 +283,10 @@ class ComprehensiveTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/implementation/ComprehensiveTypeImpl.cpp b/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/implementation/ComprehensiveTypeImpl.cpp index 7b0fc369d98..dfa08fc7503 100644 --- a/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/implementation/ComprehensiveTypeImpl.cpp +++ b/test/unittest/dds/xtypes/serializers/json/types/comprehensive_type/implementation/ComprehensiveTypeImpl.cpp @@ -232,7 +232,7 @@ template <> traits::ref_type create_dynamic_type() { eprosima::fastdds::dds::TypeSupport type(new ComprehensiveTypePubSubType()); - const auto type_name = type->getName(); + const auto type_name = type->get_name(); type->register_type_object_representation(); diff --git a/test/unittest/rtps/builtin/CMakeLists.txt b/test/unittest/rtps/builtin/CMakeLists.txt index a2bc6004d9e..358ce8f234c 100644 --- a/test/unittest/rtps/builtin/CMakeLists.txt +++ b/test/unittest/rtps/builtin/CMakeLists.txt @@ -16,7 +16,6 @@ set(BUILTIN_DATA_SERIALIZATION_TESTS_SOURCE BuiltinDataSerializationTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/ParameterList.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/xtypes/exception/Exception.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/xtypes/type_representation/dds_xtypes_typeobjectPubSubTypes.cxx ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp diff --git a/test/unittest/rtps/discovery/CMakeLists.txt b/test/unittest/rtps/discovery/CMakeLists.txt index 51721bcbf12..1ef99c89db9 100644 --- a/test/unittest/rtps/discovery/CMakeLists.txt +++ b/test/unittest/rtps/discovery/CMakeLists.txt @@ -16,7 +16,6 @@ set(EDPTESTS_SOURCE EdpTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp @@ -114,7 +113,6 @@ set(PDPTESTS_SOURCE PDPTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/ParameterList.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/xtypes/type_representation/dds_xtypes_typeobjectPubSubTypes.cxx ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp diff --git a/test/unittest/rtps/network/CMakeLists.txt b/test/unittest/rtps/network/CMakeLists.txt index e28cf657a75..ad528dcda57 100644 --- a/test/unittest/rtps/network/CMakeLists.txt +++ b/test/unittest/rtps/network/CMakeLists.txt @@ -107,7 +107,6 @@ add_executable(ExternalLocatorsTests ExternalLocatorsTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/xtypes/exception/Exception.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp diff --git a/test/unittest/rtps/reader/CMakeLists.txt b/test/unittest/rtps/reader/CMakeLists.txt index 61980797160..09585886e51 100644 --- a/test/unittest/rtps/reader/CMakeLists.txt +++ b/test/unittest/rtps/reader/CMakeLists.txt @@ -289,7 +289,6 @@ set(STATEFUL_READER_TESTS_SOURCE StatefulReaderTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/ParameterList.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp diff --git a/test/unittest/statistics/dds/CMakeLists.txt b/test/unittest/statistics/dds/CMakeLists.txt index 5fff5dc79d7..174463c3c5c 100644 --- a/test/unittest/statistics/dds/CMakeLists.txt +++ b/test/unittest/statistics/dds/CMakeLists.txt @@ -80,7 +80,6 @@ if (FASTDDS_STATISTICS) DomainParticipantStatisticsListenerTests.cpp) add_executable(DomainParticipantStatisticsListenerTests - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/statistics/fastdds/domain/DomainParticipantStatisticsListener.cpp ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/monitorservice_typesPubSubTypes.cxx @@ -172,7 +171,6 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/ContentFilteredTopicImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/qos/TopicQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/Topic.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicProxyFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TypeSupport.cpp @@ -353,7 +351,6 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/ContentFilteredTopicImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/qos/TopicQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/Topic.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicProxyFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TypeSupport.cpp diff --git a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp index ca9b5aca931..0a31919979d 100644 --- a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp +++ b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp @@ -37,46 +37,53 @@ class TopicDataTypeMock : public eprosima::fastdds::dds::TopicDataType TopicDataTypeMock() : TopicDataType() { - m_typeSize = 4u; - setName("footype"); + max_serialized_type_size = 4u; + set_name("footype"); } bool serialize( const void* const /*data*/, - eprosima::fastdds::rtps::SerializedPayload_t* /*payload*/) override + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, + eprosima::fastdds::dds::DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* /*payload*/, + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const /*data*/) override + uint32_t calculate_serialized_size( + const void* const /*data*/, + eprosima::fastdds::dds::DataRepresentationId_t /*data_representation*/) override { - return []()->uint32_t - { - return 0; - }; + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& /*payload*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - eprosima::fastdds::rtps::InstanceHandle_t* /*ihandle*/, + eprosima::fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -84,12 +91,12 @@ class TopicDataTypeMock : public eprosima::fastdds::dds::TopicDataType void clearName() { - setName(""); + set_name(""); } private: - using eprosima::fastdds::dds::TopicDataType::getSerializedSizeProvider; + using eprosima::fastdds::dds::TopicDataType::calculate_serialized_size; using eprosima::fastdds::dds::TopicDataType::serialize; }; diff --git a/test/unittest/statistics/dds/StatisticsDomainParticipantTests.cpp b/test/unittest/statistics/dds/StatisticsDomainParticipantTests.cpp index 5f468da82b0..caabacabd94 100644 --- a/test/unittest/statistics/dds/StatisticsDomainParticipantTests.cpp +++ b/test/unittest/statistics/dds/StatisticsDomainParticipantTests.cpp @@ -82,46 +82,53 @@ class TopicDataTypeMock : public eprosima::fastdds::dds::TopicDataType TopicDataTypeMock() : eprosima::fastdds::dds::TopicDataType() { - m_typeSize = 4u; - setName("footype"); + max_serialized_type_size = 4u; + set_name("footype"); } bool serialize( const void* const /*data*/, - fastdds::rtps::SerializedPayload_t* /*payload*/) override + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::dds::DataRepresentationId_t /*data_representation*/) override { return true; } bool deserialize( - fastdds::rtps::SerializedPayload_t* /*payload*/, + fastdds::rtps::SerializedPayload_t& /*payload*/, void* /*data*/) override { return true; } - std::function getSerializedSizeProvider( - const void* const /*data*/) override + uint32_t calculate_serialized_size( + const void* const /*data*/, + fastdds::dds::DataRepresentationId_t /*data_representation*/) override { - return []()->uint32_t - { - return 0; - }; + return 0; } - void* createData() override + void* create_data() override { return nullptr; } - void deleteData( + void delete_data( void* /*data*/) override { } - bool getKey( + bool compute_key( + fastdds::rtps::SerializedPayload_t& /*payload*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, + bool /*force_md5*/) override + { + return true; + } + + bool compute_key( const void* const /*data*/, - fastdds::rtps::InstanceHandle_t* /*ihandle*/, + fastdds::rtps::InstanceHandle_t& /*ihandle*/, bool /*force_md5*/) override { return true; @@ -129,7 +136,7 @@ class TopicDataTypeMock : public eprosima::fastdds::dds::TopicDataType private: - using eprosima::fastdds::dds::TopicDataType::getSerializedSizeProvider; + using eprosima::fastdds::dds::TopicDataType::calculate_serialized_size; using eprosima::fastdds::dds::TopicDataType::serialize; }; @@ -608,7 +615,7 @@ TEST_F(StatisticsDomainParticipantTests, EnableStatisticsDataWriterFailureIncomp eprosima::fastdds::dds::TypeSupport count_type(new EntityCountPubSubType); eprosima::fastdds::dds::TypeSupport null_type(nullptr); eprosima::fastdds::dds::TypeSupport invalid_type(new TopicDataTypeMock); - invalid_type->setName(reserved_statistics_type_name); + invalid_type->set_name(reserved_statistics_type_name); participant->register_type(invalid_type); participant->register_type(physical_data_type); @@ -682,9 +689,9 @@ TEST_F(StatisticsDomainParticipantTests, EnableStatisticsDataWriterFailureIncomp // Create topic eprosima::fastdds::dds::Topic* invalid_topic = participant->create_topic(HISTORY_LATENCY_TOPIC, - count_type->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); - participant->create_topic(HEARTBEAT_COUNT_TOPIC, count_type->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); - participant->create_topic(PHYSICAL_DATA_TOPIC, physical_data_type->getName(), + count_type->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + participant->create_topic(HEARTBEAT_COUNT_TOPIC, count_type->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + participant->create_topic(PHYSICAL_DATA_TOPIC, physical_data_type->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); // 2. Check call to enable_statistics_datawriter @@ -744,7 +751,7 @@ TEST_F(StatisticsDomainParticipantTests, DeleteParticipantAfterDeleteContainedEn // 2. Create a sample topic participant->create_topic(HEARTBEAT_COUNT_TOPIC, - count_type->getName(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); + count_type->get_name(), eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); DomainParticipant* statistics_participant = DomainParticipant::narrow(participant); ASSERT_NE(statistics_participant, nullptr); diff --git a/test/unittest/statistics/rtps/CMakeLists.txt b/test/unittest/statistics/rtps/CMakeLists.txt index de69247ee3e..03036f85d9b 100644 --- a/test/unittest/statistics/rtps/CMakeLists.txt +++ b/test/unittest/statistics/rtps/CMakeLists.txt @@ -66,7 +66,6 @@ set(STATISTICS_RTPS_MONITORSERVICETESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/ParameterList.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/WriterProxyData.cpp diff --git a/test/unittest/xmlparser/CMakeLists.txt b/test/unittest/xmlparser/CMakeLists.txt index 397058bc3ea..d88feab7df0 100644 --- a/test/unittest/xmlparser/CMakeLists.txt +++ b/test/unittest/xmlparser/CMakeLists.txt @@ -80,7 +80,6 @@ set(XMLPROFILEPARSER_SOURCE XMLProfileParserTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/xtypes/exception/Exception.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp @@ -174,7 +173,6 @@ set(XMLPARSER_SOURCE XMLElementParserTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/xtypes/exception/Exception.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp @@ -293,7 +291,6 @@ set(XMLENDPOINTPARSERTESTS_SOURCE XMLEndpointParserTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/xtypes/exception/Exception.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp @@ -378,7 +375,6 @@ set(XMLLOADFILE_SOURCE XMLLoadFileTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/xtypes/exception/Exception.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp