Skip to content

Commit

Permalink
Refs #21325: Remove FASTCDR_VERSION_MAJOR == 1 related code
Browse files Browse the repository at this point in the history
Signed-off-by: eduponz <[email protected]>
  • Loading branch information
EduPonz committed Jul 16, 2024
1 parent fa5ad77 commit bd4f8be
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ $ctx.directIncludeDependencies : {include | %include "$include$.i"}; separator="
%}

%include <fastcdr/config.h>
#if FASTCDR_VERSION_MAJOR > 1
%import(module="fastdds") "fastcdr/xcdr/optional.hpp"
#endif
%import(module="fastdds") "fastdds/dds/core/LoanableCollection.hpp"
%import(module="fastdds") "fastdds/dds/core/LoanableTypedCollection.hpp"
%import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp"
Expand Down Expand Up @@ -147,9 +145,6 @@ $endif$

member_getters(struct_name, member) ::= <<
$if(member.annotationOptional)$
#if FASTCDR_VERSION_MAJOR == 1
%ignore $struct_name$::$member.name$($member.typecode.cppTypename$&&);
#else
%ignore eprosima::fastcdr::optional::value;
%ignore eprosima::fastcdr::optional::reset;
%template($member.typecode.noScopedCppTypename$Opt) eprosima::fastcdr::optional<$member.typecode.cppTypename$>;
Expand All @@ -163,7 +158,6 @@ $if(member.annotationOptional)$
}
}
%ignore $struct_name$::$member.name$(eprosima::fastcdr::optional<$member.typecode.cppTypename$>&&);
#endif
$else$
%ignore $struct_name$::$member.name$($member.typecode.cppTypename$&&);
$endif$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ $member_list$
$struct.name$PubSubType::$struct.name$PubSubType()
{
$if(ctx.GenerateTypesROS2)$setName("$struct.ROS2Scopedname$");$else$setName("$struct.scopedname$");$endif$
uint32_t type_size =
#if FASTCDR_VERSION_MAJOR == 1
static_cast<uint32_t>($struct.name$::getMaxCdrSerializedSize());
#else
$struct.cScopedname$_max_cdr_typesize;
#endif
uint32_t type_size = $struct.cScopedname$_max_cdr_typesize;
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
m_typeSize = type_size + 4; /*encapsulation*/
m_isGetKeyDefined = $if(struct.hasKey)$true$else$false$endif$;
Expand Down Expand Up @@ -90,12 +85,10 @@ bool $struct.name$PubSubType::serialize(
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;
#if FASTCDR_VERSION_MAJOR > 1
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$ :
$if(struct.annotationFinal)$eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2$elseif(struct.annotationAppendable)$eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2$elseif(struct.annotationMutable)$eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR2$endif$);
#endif // FASTCDR_VERSION_MAJOR > 1

try
{
Expand All @@ -110,11 +103,7 @@ bool $struct.name$PubSubType::serialize(
}

// Get the serialized length
#if FASTCDR_VERSION_MAJOR == 1
payload->length = static_cast<uint32_t>(ser.getSerializedDataLength());
#else
payload->length = static_cast<uint32_t>(ser.get_serialized_data_length());
#endif // FASTCDR_VERSION_MAJOR == 1
return true;
}

Expand All @@ -132,9 +121,6 @@ bool $struct.name$PubSubType::deserialize(

// Object that deserializes the data.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN
#if FASTCDR_VERSION_MAJOR == 1
, eprosima::fastcdr::Cdr::CdrType::DDS_CDR
#endif // FASTCDR_VERSION_MAJOR == 1
);

// Deserialize encapsulation.
Expand All @@ -158,11 +144,6 @@ std::function<uint32_t()> $struct.name$PubSubType::getSerializedSizeProvider(
{
return [data, data_representation]() -> uint32_t
{
#if FASTCDR_VERSION_MAJOR == 1
static_cast<void>(data_representation);
return static_cast<uint32_t>(type::getCdrSerializedSize(*static_cast<$struct.name$*>(data))) +
4u /*encapsulation*/;
#else
try
{
eprosima::fastcdr::CdrSizeCalculator calculator(
Expand All @@ -177,7 +158,6 @@ std::function<uint32_t()> $struct.name$PubSubType::getSerializedSizeProvider(
{
return 0;
}
#endif // FASTCDR_VERSION_MAJOR == 1
};
}

Expand Down Expand Up @@ -210,19 +190,11 @@ bool $struct.name$PubSubType::getKey(

// Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1);
#if FASTCDR_VERSION_MAJOR == 1
p_type->serializeKey(ser);
#else
eprosima::fastcdr::serialize_key(ser, *p_type);
#endif // FASTCDR_VERSION_MAJOR == 1
if (force_md5 || $struct.cScopedname$_max_key_cdr_typesize > 16)
{
m_md5.init();
#if FASTCDR_VERSION_MAJOR == 1
m_md5.update(m_keyBuffer, static_cast<unsigned int>(ser.getSerializedDataLength()));
#else
m_md5.update(m_keyBuffer, static_cast<unsigned int>(ser.get_serialized_data_length()));
#endif // FASTCDR_VERSION_MAJOR == 1
m_md5.finalize();
for (uint8_t i = 0; i < 16; ++i)
{
Expand Down

0 comments on commit bd4f8be

Please sign in to comment.