Skip to content

Commit

Permalink
Refs #21219: Uncrustify
Browse files Browse the repository at this point in the history
Signed-off-by: eduponz <[email protected]>
  • Loading branch information
EduPonz committed Jun 24, 2024
1 parent a82b078 commit e19e467
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 87 deletions.
85 changes: 51 additions & 34 deletions test/profiling/MemoryTestTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,51 +22,58 @@
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::serialize(
void* data,
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
eprosima::fastdds::dds::DataRepresentationId_t)
void* data,
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
eprosima::fastdds::dds::DataRepresentationId_t)
{
return serialize(data,payload);
return serialize(data, payload);
}

bool MemoryDataType::deserialize(SerializedPayload_t* payload,void * data)
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)
std::function<uint32_t()> MemoryDataType::getSerializedSizeProvider(
void* data,
eprosima::fastdds::dds::DataRepresentationId_t)
{
return getSerializedSizeProvider(data);
}
Expand All @@ -76,14 +83,17 @@ 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;
Expand All @@ -92,14 +102,16 @@ bool TestCommandDataType::serialize(void*data,SerializedPayload_t* payload)
}

bool TestCommandDataType::serialize(
void* data,
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
eprosima::fastdds::dds::DataRepresentationId_t)
void* data,
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
eprosima::fastdds::dds::DataRepresentationId_t)
{
return serialize(data,payload);
return serialize(data, payload);
}

bool TestCommandDataType::deserialize(SerializedPayload_t* payload,void * data)
bool TestCommandDataType::deserialize(
SerializedPayload_t* payload,
void* data)
{
TestCommandType* t = (TestCommandType*)data;
// cout << "PAYLOAD LENGTH: "<<payload->length << endl;
Expand All @@ -109,19 +121,22 @@ 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)
std::function<uint32_t()> TestCommandDataType::getSerializedSizeProvider(
void* data,
eprosima::fastdds::dds::DataRepresentationId_t)
{
return getSerializedSizeProvider(data);
}
Expand All @@ -131,7 +146,9 @@ void* TestCommandDataType::createData()

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

void TestCommandDataType::deleteData(
void* data)
{

delete((TestCommandType*)data);
Expand Down
164 changes: 111 additions & 53 deletions test/profiling/MemoryTestTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,63 +24,98 @@

class MemoryType
{
public:
public:

uint32_t seqnum;
std::vector<uint8_t> data;
uint32_t seqnum;
std::vector<uint8_t> data;

MemoryType(): seqnum(0) {}
MemoryType()
: seqnum(0)
{
}

MemoryType(uint32_t number) :
seqnum(0), data(number,0) {}
MemoryType(
uint32_t number)
: seqnum(0)
, data(number, 0)
{
}

~MemoryType()
{
}

~MemoryType() {}
};


inline bool operator==(const MemoryType& lt1, const MemoryType& lt2)
inline bool operator ==(
const MemoryType& lt1,
const MemoryType& lt2)
{
if(lt1.seqnum!=lt2.seqnum)
if (lt1.seqnum != lt2.seqnum)
{
return false;
if(lt1.data.size()!=lt2.data.size())
}
if (lt1.data.size() != lt2.data.size())
{
return false;
for(size_t i = 0;i<lt1.data.size();++i)
}
for (size_t i = 0; i < lt1.data.size(); ++i)
{
if(lt1.data.at(i) != lt2.data.at(i))
if (lt1.data.at(i) != lt2.data.at(i))
{
return false;
}
}
return true;
}

class MemoryDataType : public eprosima::fastrtps::TopicDataType
{
public:
MemoryDataType()
{
setName("MemoryType");
m_typeSize = 17000;
m_isGetKeyDefined = false;
};
~MemoryDataType(){};
bool serialize(void*data, eprosima::fastrtps::rtps::SerializedPayload_t* payload) override;
bool serialize(
public:

MemoryDataType()
{
setName("MemoryType");
m_typeSize = 17000;
m_isGetKeyDefined = false;
}

~MemoryDataType()
{
}

bool serialize(
void* data,
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) override;
std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
std::function<uint32_t()> getSerializedSizeProvider(
bool deserialize(
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
void* data) override;
std::function<uint32_t()> getSerializedSizeProvider(
void* data) override;
std::function<uint32_t()> getSerializedSizeProvider(
void* data,
eprosima::fastdds::dds::DataRepresentationId_t data_representation) override;
void* createData() override;
void deleteData(void* data) override;
bool getKey(void* /*data*/, eprosima::fastrtps::rtps::InstanceHandle_t* /*ihandle*/, bool force_md5 = false) override {
(void)force_md5;
return false;
}
void* createData() override;
void deleteData(
void* data) override;
bool getKey(
void* /*data*/,
eprosima::fastrtps::rtps::InstanceHandle_t* /*ihandle*/,
bool force_md5 = false) override
{
(void)force_md5;
return false;
}

};

enum TESTCOMMAND:uint32_t{
enum TESTCOMMAND : uint32_t
{
DEFAULT,
READY,
BEGIN,
Expand All @@ -91,38 +126,61 @@ enum TESTCOMMAND:uint32_t{
typedef struct TestCommandType
{
TESTCOMMAND m_command;
TestCommandType(){
TestCommandType()
{
m_command = DEFAULT;
}
TestCommandType(TESTCOMMAND com):m_command(com){}

TestCommandType(
TESTCOMMAND com)
: m_command(com)
{
}

}TestCommandType;

class TestCommandDataType : public eprosima::fastrtps::TopicDataType
{
public:
TestCommandDataType()
{
setName("TestCommandType");
m_typeSize = 4;
m_isGetKeyDefined = false;
};
~TestCommandDataType(){};
bool serialize(void*data,eprosima::fastrtps::rtps::SerializedPayload_t* payload) override;
bool serialize(
public:

TestCommandDataType()
{
setName("TestCommandType");
m_typeSize = 4;
m_isGetKeyDefined = false;
}

~TestCommandDataType()
{
}

bool serialize(
void* data,
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) override;
std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
std::function<uint32_t()> getSerializedSizeProvider(
bool deserialize(
eprosima::fastrtps::rtps::SerializedPayload_t* payload,
void* data) override;
std::function<uint32_t()> getSerializedSizeProvider(
void* data) override;
std::function<uint32_t()> getSerializedSizeProvider(
void* data,
eprosima::fastdds::dds::DataRepresentationId_t data_representation) override;
void* createData() override;
void deleteData(void* data) override;
bool getKey(void* /*data*/, eprosima::fastrtps::rtps::InstanceHandle_t* /*ihandle*/, bool force_md5 = false) override {
(void)force_md5;
return false;
}
void* createData() override;
void deleteData(
void* data) override;
bool getKey(
void* /*data*/,
eprosima::fastrtps::rtps::InstanceHandle_t* /*ihandle*/,
bool force_md5 = false) override
{
(void)force_md5;
return false;
}

};


Expand Down

0 comments on commit e19e467

Please sign in to comment.