Skip to content

Commit

Permalink
Refs #21349. Apply suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware committed Jul 16, 2024
1 parent 8a4c10d commit 1189c98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,25 @@ public:

eProsima_user_DllExport bool serialize(
const void* const data,
eprosima::fastdds::rtps::SerializedPayload_t* payload,
eprosima::fastdds::rtps::SerializedPayload_t& payload,
eprosima::fastdds::dds::DataRepresentationId_t data_representation) override;

eProsima_user_DllExport bool deserialize(
eprosima::fastdds::rtps::SerializedPayload_t* payload,
eprosima::fastdds::rtps::SerializedPayload_t& payload,
void* data) override;

eProsima_user_DllExport uint32_t calculate_serialized_size(
const void* const data,
eprosima::fastdds::dds::DataRepresentationId_t data_representation) override;

eProsima_user_DllExport bool compute_key(
eprosima::fastdds::rtps::SerializedPayload_t* payload,
eprosima::fastdds::rtps::InstanceHandle_t* ihandle,
eprosima::fastdds::rtps::SerializedPayload_t& payload,
eprosima::fastdds::rtps::InstanceHandle_t& ihandle,
bool force_md5 = false) override;

eProsima_user_DllExport bool compute_key(
const void* const data,
eprosima::fastdds::rtps::InstanceHandle_t* ihandle,
eprosima::fastdds::rtps::InstanceHandle_t& ihandle,
bool force_md5 = false) override;

eProsima_user_DllExport void* create_data() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ $struct.name$PubSubType::~$struct.name$PubSubType()

bool $struct.name$PubSubType::serialize(
const void* const data,
SerializedPayload_t* payload,
SerializedPayload_t& payload,
DataRepresentationId_t data_representation)
{
const $struct.name$* p_type = static_cast<const $struct.name$*>(data);

// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->max_size);
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
// Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
ser.set_encoding_flag(
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
$if(struct.annotationFinal || struct.annotationAppendable)$eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR $elseif(struct.annotationMutable)$eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR$endif$ :
Expand All @@ -103,12 +103,12 @@ bool $struct.name$PubSubType::serialize(
}

// Get the serialized length
payload->length = static_cast<uint32_t>(ser.get_serialized_data_length());
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
return true;
}

bool $struct.name$PubSubType::deserialize(
SerializedPayload_t* payload,
SerializedPayload_t& payload,
void* data)
{
try
Expand All @@ -117,14 +117,14 @@ bool $struct.name$PubSubType::deserialize(
$struct.name$* p_type = static_cast<$struct.name$*>(data);

// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->length);
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);

// Object that deserializes the data.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);

// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;

// Deserialize the object.
deser \>> *p_type;
Expand Down Expand Up @@ -169,8 +169,8 @@ void $struct.name$PubSubType::delete_data(
}

bool $struct.name$PubSubType::compute_key(
SerializedPayload_t* payload,
InstanceHandle_t* handle,
SerializedPayload_t& payload,
InstanceHandle_t& handle,
bool force_md5)
{
if (!is_compute_key_provided)
Expand All @@ -189,7 +189,7 @@ bool $struct.name$PubSubType::compute_key(

bool $struct.name$PubSubType::compute_key(
const void* const data,
InstanceHandle_t* handle,
InstanceHandle_t& handle,
bool force_md5)
{
if (!is_compute_key_provided)
Expand All @@ -213,14 +213,14 @@ bool $struct.name$PubSubType::compute_key(
md5_.finalize();
for (uint8_t i = 0; i < 16; ++i)
{
handle->value[i] = md5_.digest[i];
handle.value[i] = md5_.digest[i];
}
}
else
{
for (uint8_t i = 0; i < 16; ++i)
{
handle->value[i] = key_buffer_[i];
handle.value[i] = key_buffer_[i];
}
}
return true;
Expand Down

0 comments on commit 1189c98

Please sign in to comment.