From dc0e829d97b1c3b11f626edeedce43366d480ef4 Mon Sep 17 00:00:00 2001 From: Eduardo Ponz Segrelles Date: Fri, 21 Jun 2024 13:18:25 +0200 Subject: [PATCH] Adjust for const changes in DataWriter APIs (#147) Signed-off-by: eduponz --- types/KeylessShapeTypePubSubTypes.cxx | 12 ++++++------ types/KeylessShapeTypePubSubTypes.h | 10 +++++----- types/ShapePubSubTypes.cxx | 12 ++++++------ types/ShapePubSubTypes.h | 10 +++++----- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/types/KeylessShapeTypePubSubTypes.cxx b/types/KeylessShapeTypePubSubTypes.cxx index b8df17d..b5caee3 100644 --- a/types/KeylessShapeTypePubSubTypes.cxx +++ b/types/KeylessShapeTypePubSubTypes.cxx @@ -59,11 +59,11 @@ namespace shapes_demo_typesupport { } bool KeylessShapeTypePubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - KeylessShapeType* p_type = static_cast(data); + const KeylessShapeType* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -135,7 +135,7 @@ namespace shapes_demo_typesupport { } std::function KeylessShapeTypePubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -152,7 +152,7 @@ namespace shapes_demo_typesupport { eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -175,7 +175,7 @@ namespace shapes_demo_typesupport { } bool KeylessShapeTypePubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -184,7 +184,7 @@ namespace shapes_demo_typesupport { return false; } - KeylessShapeType* p_type = static_cast(data); + const KeylessShapeType* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/types/KeylessShapeTypePubSubTypes.h b/types/KeylessShapeTypePubSubTypes.h index 20603a7..84afbf3 100644 --- a/types/KeylessShapeTypePubSubTypes.h +++ b/types/KeylessShapeTypePubSubTypes.h @@ -57,14 +57,14 @@ namespace shapes_demo_typesupport eProsima_user_DllExport ~KeylessShapeTypePubSubType() override; eProsima_user_DllExport bool serialize( - void* data, + const void* const data, eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, + const void* const data, eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; @@ -73,17 +73,17 @@ namespace shapes_demo_typesupport void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, + const void* const data, eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; diff --git a/types/ShapePubSubTypes.cxx b/types/ShapePubSubTypes.cxx index d087868..db5bb1f 100644 --- a/types/ShapePubSubTypes.cxx +++ b/types/ShapePubSubTypes.cxx @@ -57,11 +57,11 @@ ShapeTypePubSubType::~ShapeTypePubSubType() } bool ShapeTypePubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - ShapeType* p_type = static_cast(data); + const ShapeType* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool ShapeTypePubSubType::deserialize( } std::function ShapeTypePubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function ShapeTypePubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void ShapeTypePubSubType::deleteData( } bool ShapeTypePubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool ShapeTypePubSubType::getKey( return false; } - ShapeType* p_type = static_cast(data); + const ShapeType* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/types/ShapePubSubTypes.h b/types/ShapePubSubTypes.h index 9508a0a..2e8aef0 100644 --- a/types/ShapePubSubTypes.h +++ b/types/ShapePubSubTypes.h @@ -53,14 +53,14 @@ class ShapeTypePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~ShapeTypePubSubType() override; eProsima_user_DllExport bool serialize( - void* data, + const void* const data, eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, + const void* const data, eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; @@ -69,17 +69,17 @@ class ShapeTypePubSubType : public eprosima::fastdds::dds::TopicDataType void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, + const void* const data, eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override;