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

Fastdds type support extensions #516

Closed
Closed
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
9 changes: 8 additions & 1 deletion rmw_fastrtps_cpp/src/type_support_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,22 @@ TypeSupport::TypeSupport()
{
m_isGetKeyDefined = false;
max_size_bound_ = false;
is_plain_ = false;
}

void TypeSupport::set_members(const message_type_support_callbacks_t * members)
{
members_ = members;

// Fully bound by default
#ifdef ROSIDL_TYPESUPPORT_FASTRTPS_HAS_PLAIN_TYPES
char bounds_info;
auto data_size = static_cast<uint32_t>(members->max_serialized_size(bounds_info));
max_size_bound_ = 0 != (bounds_info & ROSIDL_TYPESUPPORT_FASTRTPS_BOUNDED_TYPE);
is_plain_ = bounds_info == ROSIDL_TYPESUPPORT_FASTRTPS_PLAIN_TYPE;
#else
max_size_bound_ = true;
auto data_size = static_cast<uint32_t>(members->max_serialized_size(max_size_bound_));
#endif

// A fully bound message of size 0 is an empty message
if (max_size_bound_ && (data_size == 0) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ MessageTypeSupport<MembersType>::MessageTypeSupport(
ss << "dds_::" << message_name << "_";
this->setName(ss.str().c_str());

// Fully bound by default
// Fully bound and plain by default
this->max_size_bound_ = true;
this->is_plain_ = true;
// Encapsulation size
this->m_typeSize = 4;
if (this->members_->member_count_ != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ RequestTypeSupport<ServiceMembersType, MessageMembersType>::RequestTypeSupport(
ss << "dds_::" << service_name << "_Request_";
this->setName(ss.str().c_str());

// Fully bound by default
// Fully bound and plain by default
this->max_size_bound_ = true;
this->is_plain_ = true;
// Encapsulation size
this->m_typeSize = 4;
if (this->members_->member_count_ != 0) {
Expand Down Expand Up @@ -79,8 +80,9 @@ ResponseTypeSupport<ServiceMembersType, MessageMembersType>::ResponseTypeSupport
ss << "dds_::" << service_name << "_Response_";
this->setName(ss.str().c_str());

// Fully bound by default
// Fully bound and plain by default
this->max_size_bound_ = true;
this->is_plain_ = true;
// Encapsulation size
this->m_typeSize = 4;
if (this->members_->member_count_ != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ TypeSupport<MembersType>::TypeSupport(const void * ros_type_support)
{
m_isGetKeyDefined = false;
max_size_bound_ = false;
is_plain_ = false;
}

// C++ specialization
Expand Down Expand Up @@ -829,9 +830,15 @@ size_t TypeSupport<MembersType>::calculateMaxSerializedSize(
size_t array_size = 1;
if (member->is_array_) {
array_size = member->array_size_;

// Whether it is unbounded.
if (0u == array_size) {
this->max_size_bound_ = false;
}

// Whether it is a sequence.
if (0 == array_size || member->is_upper_bound_) {
this->max_size_bound_ = false;
this->is_plain_ = false;
current_alignment += padding +
eprosima::fastcdr::Cdr::alignment(current_alignment, padding);
}
Expand Down Expand Up @@ -866,6 +873,7 @@ size_t TypeSupport<MembersType>::calculateMaxSerializedSize(
case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING:
{
this->max_size_bound_ = false;
this->is_plain_ = false;
size_t character_size =
(member->type_id_ == rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING) ? 4 : 1;
for (size_t index = 0; index < array_size; ++index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ class TypeSupport : public eprosima::fastdds::dds::TopicDataType
RMW_FASTRTPS_SHARED_CPP_PUBLIC
void deleteData(void * data) override;

RMW_FASTRTPS_SHARED_CPP_PUBLIC
inline bool is_bounded() const
#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
override
#endif
{
return max_size_bound_;
}

RMW_FASTRTPS_SHARED_CPP_PUBLIC
inline bool is_plain() const
#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN
override
#endif
{
return is_plain_;
}

RMW_FASTRTPS_SHARED_CPP_PUBLIC
virtual ~TypeSupport() {}

Expand All @@ -85,6 +103,7 @@ class TypeSupport : public eprosima::fastdds::dds::TopicDataType
TypeSupport();

bool max_size_bound_;
bool is_plain_;
};

} // namespace rmw_fastrtps_shared_cpp
Expand Down
1 change: 1 addition & 0 deletions rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TypeSupport::TypeSupport()
{
m_isGetKeyDefined = false;
max_size_bound_ = false;
is_plain_ = false;
}

void TypeSupport::deleteData(void * data)
Expand Down