From 727dcfd2183ce8c067a0c8f67adf26b8d384e05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Wed, 3 Apr 2024 09:51:25 +0200 Subject: [PATCH] Refs #20738. Fix after rebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- include/fastdds/config.h.in | 4 -- test/profiling/MemoryTestTypes.cpp | 92 ++++++++++++++++++++++-------- test/profiling/MemoryTestTypes.h | 26 +++++++-- 3 files changed, 88 insertions(+), 34 deletions(-) diff --git a/include/fastdds/config.h.in b/include/fastdds/config.h.in index c92c08c9134..8b3d118edfb 100644 --- a/include/fastdds/config.h.in +++ b/include/fastdds/config.h.in @@ -103,10 +103,6 @@ // Statistics #cmakedefine FASTDDS_STATISTICS -#ifndef __has_cpp_attribute -# define __has_cpp_attribute(x) 0 -#endif // ifndef __has_cpp_attribute - // Deprecated macro #if __cplusplus >= 201402L #define FASTDDS_DEPRECATED(msg) [[ deprecated(msg) ]] diff --git a/test/profiling/MemoryTestTypes.cpp b/test/profiling/MemoryTestTypes.cpp index 8ebda73cb2a..127c9172c90 100644 --- a/test/profiling/MemoryTestTypes.cpp +++ b/test/profiling/MemoryTestTypes.cpp @@ -22,40 +22,60 @@ using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; -bool MemoryDataType::serialize(void*data,SerializedPayload_t* payload) +bool MemoryDataType::serialize( + void* data, + SerializedPayload_t* payload) { MemoryType* lt = (MemoryType*)data; *(uint32_t*)payload->data = lt->seqnum; - *(uint32_t*)(payload->data+4) = (uint32_t)lt->data.size(); + *(uint32_t*)(payload->data + 4) = (uint32_t)lt->data.size(); //std::copy(lt->data.begin(),lt->data.end(),payload->data+8); memcpy(payload->data + 8, lt->data.data(), lt->data.size()); - payload->length = (uint32_t)(8+lt->data.size()); + payload->length = (uint32_t)(8 + lt->data.size()); return true; } -bool MemoryDataType::deserialize(SerializedPayload_t* payload,void * data) +bool MemoryDataType::serialize( + void* data, + SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t) +{ + return serialize(data, payload); +} + +bool MemoryDataType::deserialize( + SerializedPayload_t* payload, + void* data) { MemoryType* lt = (MemoryType*)data; lt->seqnum = *(uint32_t*)payload->data; - uint32_t siz = *(uint32_t*)(payload->data+4); - std::copy(payload->data+8,payload->data+8+siz,lt->data.begin()); + uint32_t siz = *(uint32_t*)(payload->data + 4); + std::copy(payload->data + 8, payload->data + 8 + siz, lt->data.begin()); return true; } -std::function MemoryDataType::getSerializedSizeProvider(void* data) +std::function MemoryDataType::getSerializedSizeProvider( + void* data) { return [data]() -> uint32_t - { - MemoryType *tdata = static_cast(data); - uint32_t size = 0; + { + MemoryType* tdata = static_cast(data); + uint32_t size = 0; + + size = (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + tdata->data.size()); - size = (uint32_t)(sizeof(uint32_t) + sizeof(uint32_t) + tdata->data.size()); + return size; + }; +} - return size; - }; +std::function MemoryDataType::getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t) +{ + return getSerializedSizeProvider(data); } void* MemoryDataType::createData() @@ -63,21 +83,35 @@ void* MemoryDataType::createData() return (void*)new MemoryType(); } -void MemoryDataType::deleteData(void* data) + +void MemoryDataType::deleteData( + void* data) { delete((MemoryType*)data); } - -bool TestCommandDataType::serialize(void*data,SerializedPayload_t* payload) +bool TestCommandDataType::serialize( + void* data, + SerializedPayload_t* payload) { TestCommandType* t = (TestCommandType*)data; *(TESTCOMMAND*)payload->data = t->m_command; payload->length = 4; return true; } -bool TestCommandDataType::deserialize(SerializedPayload_t* payload,void * data) + +bool TestCommandDataType::serialize( + void* data, + SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t) +{ + return serialize(data, payload); +} + +bool TestCommandDataType::deserialize( + SerializedPayload_t* payload, + void* data) { TestCommandType* t = (TestCommandType*)data; // cout << "PAYLOAD LENGTH: "<length << endl; @@ -87,16 +121,24 @@ bool TestCommandDataType::deserialize(SerializedPayload_t* payload,void * data) return true; } -std::function TestCommandDataType::getSerializedSizeProvider(void*) +std::function TestCommandDataType::getSerializedSizeProvider( + void*) { 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; + }; +} + +std::function TestCommandDataType::getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t) +{ + return getSerializedSizeProvider(data); } void* TestCommandDataType::createData() @@ -104,7 +146,9 @@ void* TestCommandDataType::createData() return (void*)new TestCommandType(); } -void TestCommandDataType::deleteData(void* data) + +void TestCommandDataType::deleteData( + void* data) { delete((TestCommandType*)data); diff --git a/test/profiling/MemoryTestTypes.h b/test/profiling/MemoryTestTypes.h index 782be5358ee..6f6ec10fd2c 100644 --- a/test/profiling/MemoryTestTypes.h +++ b/test/profiling/MemoryTestTypes.h @@ -91,12 +91,19 @@ class MemoryDataType : public eprosima::fastdds::dds::TopicDataType bool serialize( void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload); + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; bool deserialize( eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data); + void* data) override; std::function getSerializedSizeProvider( - void* data); + void* data) override; + std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; void* createData(); void deleteData( void* data); @@ -153,12 +160,19 @@ class TestCommandDataType : public eprosima::fastdds::dds::TopicDataType bool serialize( void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload); + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; bool deserialize( eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data); + void* data) override; std::function getSerializedSizeProvider( - void* data); + void* data) override; + std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; void* createData(); void deleteData( void* data);