Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,6 @@ $typedefs : { typedef |typedef $typedef.typedefContentTypeCode.cppTypename$ $typ
struct_type(ctx, parent, struct, member_list) ::= <<
$member_list$

$if(struct.isPlain)$
$if(struct.members)$
#ifndef SWIG
namespace detail {

template<typename Tag, typename Tag::type M>
struct $struct.name$_rob
{
friend constexpr typename Tag::type get(
Tag)
{
return M;
}

};

struct $struct.name$_f
{
typedef $last(struct.members).typecode.cppTypename$ $struct.name$::* type;
friend constexpr type get(
$struct.name$_f);
};

template struct $struct.name$_rob<$struct.name$_f, &$struct.name$::m_$last(struct.members).name$>;

template <typename T, typename Tag>
inline size_t constexpr $struct.name$_offset_of()
{
return ((::size_t) &reinterpret_cast<char const volatile&>((((T*)0)->*get(Tag()))));
}

} // namespace detail
#endif // ifndef SWIG

$endif$
$endif$

$if(!struct.parent.annotatedAsNested)$
/*!
* @brief This class represents the TopicDataType of the type $struct.name$ defined by the user in the IDL file.
Expand Down Expand Up @@ -156,23 +119,8 @@ public:

#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN

eProsima_user_DllExport inline bool is_plain(
eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override
{
$if(struct.isPlain)$
if (data_representation == eprosima::fastdds::dds::DataRepresentationId_t::XCDR2_DATA_REPRESENTATION)
{
return is_plain_xcdrv2_impl();
}
else
{
return is_plain_xcdrv1_impl();
}
$else$
static_cast<void>(data_representation);
return false;
$endif$
}
eProsima_user_DllExport bool is_plain(
eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override;

#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN

Expand All @@ -191,47 +139,6 @@ private:
eprosima::fastdds::MD5 md5_;
unsigned char* key_buffer_;

$if(struct.isPlain)$

static constexpr bool is_plain_xcdrv1_impl()
{
$if(struct.members)$
return $struct.maxXCDRv1PlainTypeSerializedSize$ULL ==
(detail::$struct.name$_offset_of<$struct.name$, detail::$struct.name$_f>() +
sizeof($last(struct.members).typecode.cppTypename$));
$elseif(struct.inheritance)$
$if(struct.inheritance.isPlain)$
return $struct.maxXCDRv1PlainTypeSerializedSize$ULL ==
(detail::$struct.inheritance.name$_offset_of<$struct.inheritance.name$, detail::$struct.inheritance.name$_f>() +
sizeof($last(struct.inheritance.members).typecode.cppTypename$));
$else$
return true;
$endif$
$else$
return true;
$endif$
}

static constexpr bool is_plain_xcdrv2_impl()
{
$if(struct.members)$
return $struct.maxXCDRv2PlainTypeSerializedSize$ULL ==
(detail::$struct.name$_offset_of<$struct.name$, detail::$struct.name$_f>() +
sizeof($last(struct.members).typecode.cppTypename$));
$elseif(struct.inheritance)$
$if(struct.inheritance.isPlain)$
return $struct.maxXCDRv2PlainTypeSerializedSize$ULL ==
(detail::$struct.inheritance.name$_offset_of<$struct.inheritance.name$, detail::$struct.inheritance.name$_f>() +
sizeof($last(struct.inheritance.members).typecode.cppTypename$));
$else$
return true;
$endif$
$else$
return true;
$endif$
}

$endif$
};
$endif$
>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t;
using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t;
using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t;

$if(ctx.anyCdr)$
namespace eprosima {
namespace fastcdr {

$ctx.types:{ type | $if(type.inScope)$$if(type.typeCode.isStructType)$
bool is_$type.typeCode.cScopedname$_cdr_plain(
DataRepresentationId_t data_representation);
$endif$$endif$
}; separator="\n"$
} // namespace fastcdr
} // namespace eprosima
$endif$

$definitions; separator="\n"$

$if(ctx.thereIsStructOrUnion || ctx.thereIsInterface)$
Expand Down Expand Up @@ -170,6 +183,21 @@ void $struct.name$PubSubType::delete_data(
delete(reinterpret_cast<::$struct.scopedname$*>(data));
}

#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN

bool $struct.name$PubSubType::is_plain(
eprosima::fastdds::dds::DataRepresentationId_t data_representation) const
{
$if(struct.isPlain)$
return eprosima::fastcdr::is_$struct.cScopedname$_cdr_plain(data_representation);
$else$
static_cast<void>(data_representation);
return false;
$endif$
}

#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN

bool $struct.name$PubSubType::compute_key(
SerializedPayload_t& payload,
InstanceHandle_t& handle,
Expand Down Expand Up @@ -330,17 +358,17 @@ public:
{
// Convert DATA to pointer of your type
type* p_type = static_cast<type*>(data);

// Object that manages the raw buffer.
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;

// Deserialize the object.
deser \>> *p_type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,41 @@ eProsima_user_DllExport void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const $struct.scopedname$& data);

$if(struct.isPlain)$
$if(struct.members)$
#ifndef SWIG
namespace detail {

template<typename Tag, typename Tag::type M>
struct $struct.name$_rob
{
friend constexpr typename Tag::type get(
Tag)
{
return M;
}

};

struct $struct.name$_f
{
typedef $last(struct.members).typecode.cppTypename$ $struct.scopedname$::* type;
friend constexpr type get(
$struct.name$_f);
};

template struct $struct.name$_rob<$struct.name$_f, &$struct.scopedname$::m_$last(struct.members).name$>;

template <typename T, typename Tag>
inline std::size_t constexpr $struct.name$_offset_of()
{
return ((std::size_t) &reinterpret_cast<char const volatile&>((((T*)0)->*get(Tag()))));
}

} // namespace detail
#endif // ifndef SWIG

$endif$
$endif$

>>
Loading