Skip to content

Commit

Permalink
Refs #20738. Fix after rebase
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware committed Apr 3, 2024
1 parent 3891c3f commit b92afc8
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 34 deletions.
4 changes: 0 additions & 4 deletions include/fastdds/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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) ]]
Expand Down
92 changes: 68 additions & 24 deletions test/profiling/MemoryTestTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,62 +22,96 @@
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<uint32_t()> MemoryDataType::getSerializedSizeProvider(void* data)
std::function<uint32_t()> MemoryDataType::getSerializedSizeProvider(
void* data)
{
return [data]() -> uint32_t
{
MemoryType *tdata = static_cast<MemoryType*>(data);
uint32_t size = 0;
{
MemoryType* tdata = static_cast<MemoryType*>(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<uint32_t()> MemoryDataType::getSerializedSizeProvider(
void* data,
eprosima::fastdds::dds::DataRepresentationId_t)
{
return getSerializedSizeProvider(data);
}

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: "<<payload->length << endl;
Expand All @@ -87,24 +121,34 @@ bool TestCommandDataType::deserialize(SerializedPayload_t* payload,void * data)
return true;
}

std::function<uint32_t()> TestCommandDataType::getSerializedSizeProvider(void*)
std::function<uint32_t()> 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<uint32_t()> TestCommandDataType::getSerializedSizeProvider(
void* data,
eprosima::fastdds::dds::DataRepresentationId_t)
{
return getSerializedSizeProvider(data);
}

void* TestCommandDataType::createData()
{

return (void*)new TestCommandType();
}
void TestCommandDataType::deleteData(void* data)

void TestCommandDataType::deleteData(
void* data)
{

delete((TestCommandType*)data);
Expand Down
26 changes: 20 additions & 6 deletions test/profiling/MemoryTestTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t()> getSerializedSizeProvider(
void* data);
void* data) override;
std::function<uint32_t()> getSerializedSizeProvider(
void* data,
eprosima::fastdds::dds::DataRepresentationId_t data_representation) override;
void* createData();
void deleteData(
void* data);
Expand Down Expand Up @@ -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<uint32_t()> getSerializedSizeProvider(
void* data);
void* data) override;
std::function<uint32_t()> getSerializedSizeProvider(
void* data,
eprosima::fastdds::dds::DataRepresentationId_t data_representation) override;
void* createData();
void deleteData(
void* data);
Expand Down

0 comments on commit b92afc8

Please sign in to comment.