Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[21183] Adjust for const qualification of all data related inputs in DataWriter APIs #817

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions code/CodeTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class HelloWorld
class HelloWorldPubSubType : public TopicDataType
{
bool serialize(
void* data,
const void* const data,
rtps::SerializedPayload_t* payload) override
{
return false;
Expand All @@ -50,7 +50,7 @@ class HelloWorldPubSubType : public TopicDataType
}

std::function<uint32_t()> getSerializedSizeProvider(
void* data) override
const void* const data) override
{
return []
{
Expand All @@ -69,7 +69,7 @@ class HelloWorldPubSubType : public TopicDataType
}

bool getKey(
void* data,
const void* const data,
rtps::InstanceHandle_t* ihandle,
bool force_md5 = false) override
{
Expand Down
12 changes: 6 additions & 6 deletions code/DDSCodeTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ class CustomDataType : public TopicDataType
}

bool serialize(
void* data,
const void* const data,
eprosima::fastdds::rtps::SerializedPayload_t* payload) override
{
return true;
Expand All @@ -1538,7 +1538,7 @@ class CustomDataType : public TopicDataType
}

std::function<uint32_t()> getSerializedSizeProvider(
void* data) override
const void* const data) override
{
return std::function<uint32_t()>();
}
Expand All @@ -1554,7 +1554,7 @@ class CustomDataType : public TopicDataType
}

bool getKey(
void* data,
const void* const data,
eprosima::fastdds::rtps::InstanceHandle_t* ihandle,
bool force_md5) override
{
Expand Down Expand Up @@ -6914,7 +6914,7 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp
}

bool serialize(
void* data,
const void* const data,
eprosima::fastdds::rtps::SerializedPayload_t* payload) override
{
return true;
Expand All @@ -6928,7 +6928,7 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp
}

std::function<uint32_t()> getSerializedSizeProvider(
void* data) override
const void* const data) override
{
return std::function<uint32_t()>();
}
Expand All @@ -6944,7 +6944,7 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp
}

bool getKey(
void* data,
const void* const data,
eprosima::fastdds::rtps::InstanceHandle_t* ihandle,
bool force_md5) override
{
Expand Down
12 changes: 6 additions & 6 deletions code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ HelloWorldPubSubType::~HelloWorldPubSubType()
}

bool HelloWorldPubSubType::serialize(
void* data,
const void* const data,
SerializedPayload_t* payload,
DataRepresentationId_t data_representation)
{
HelloWorld* p_type = static_cast<HelloWorld*>(data);
const HelloWorld* p_type = static_cast<const HelloWorld*>(data);

// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->max_size);
Expand Down Expand Up @@ -133,7 +133,7 @@ bool HelloWorldPubSubType::deserialize(
}

std::function<uint32_t()> HelloWorldPubSubType::getSerializedSizeProvider(
void* data,
const void* const data,
DataRepresentationId_t data_representation)
{
return [data, data_representation]() -> uint32_t
Expand All @@ -150,7 +150,7 @@ std::function<uint32_t()> HelloWorldPubSubType::getSerializedSizeProvider(
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
size_t current_alignment {0};
return static_cast<uint32_t>(calculator.calculate_serialized_size(
*static_cast<HelloWorld*>(data), current_alignment)) +
*static_cast<const HelloWorld*>(data), current_alignment)) +
4u /*encapsulation*/;
}
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
Expand All @@ -173,7 +173,7 @@ void HelloWorldPubSubType::deleteData(
}

bool HelloWorldPubSubType::getKey(
void* data,
const void* const data,
InstanceHandle_t* handle,
bool force_md5)
{
Expand All @@ -182,7 +182,7 @@ bool HelloWorldPubSubType::getKey(
return false;
}

HelloWorld* p_type = static_cast<HelloWorld*>(data);
const HelloWorld* p_type = static_cast<const HelloWorld*>(data);

// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(m_keyBuffer),
Expand Down
10 changes: 5 additions & 5 deletions code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType
eProsima_user_DllExport ~HelloWorldPubSubType() 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;

Expand All @@ -69,17 +69,17 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType
void* data) override;

eProsima_user_DllExport std::function<uint32_t()> getSerializedSizeProvider(
void* data) override
const void* const data) override
{
return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION);
}

eProsima_user_DllExport std::function<uint32_t()> 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;

Expand Down