From 723c5041c1532611fad95a93b3d01ddbdc758e64 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 17 Mar 2021 08:16:55 +0100 Subject: [PATCH 1/6] Added is_plain_ attribute to base TypeSupport. Signed-off-by: Miguel Company --- .../include/rmw_fastrtps_shared_cpp/TypeSupport.hpp | 1 + rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp index b31469318..15df939e4 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp @@ -85,6 +85,7 @@ class TypeSupport : public eprosima::fastdds::dds::TopicDataType TypeSupport(); bool max_size_bound_; + bool is_plain_; }; } // namespace rmw_fastrtps_shared_cpp diff --git a/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp b/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp index 1baf926fb..79d756b5f 100644 --- a/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp +++ b/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp @@ -30,6 +30,7 @@ TypeSupport::TypeSupport() { m_isGetKeyDefined = false; max_size_bound_ = false; + is_plain_ = false; } void TypeSupport::deleteData(void * data) From 81777e72f098cdd68880c77a86c823ec5ee2e7e2 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 17 Mar 2021 09:25:50 +0100 Subject: [PATCH 2/6] Added new methods to base TypeSupport. Signed-off-by: Miguel Company --- .../rmw_fastrtps_shared_cpp/TypeSupport.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp index 15df939e4..72c905a88 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp @@ -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() {} From 89ccf306400224bd300507f0a2449ff42f4c02b5 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 17 Mar 2021 09:43:16 +0100 Subject: [PATCH 3/6] Updates on rmw_fastrtps_cpp. Signed-off-by: Miguel Company --- rmw_fastrtps_cpp/src/type_support_common.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rmw_fastrtps_cpp/src/type_support_common.cpp b/rmw_fastrtps_cpp/src/type_support_common.cpp index df8cfa101..ef5567641 100644 --- a/rmw_fastrtps_cpp/src/type_support_common.cpp +++ b/rmw_fastrtps_cpp/src/type_support_common.cpp @@ -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(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(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) ) { From 8d399697ce3e0e0b8da4d8dff90eba1f690b87df Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 17 Mar 2021 10:01:39 +0100 Subject: [PATCH 4/6] Updates on rmw_fastrtps_dynamic_cpp. Signed-off-by: Miguel Company --- .../MessageTypeSupport_impl.hpp | 3 ++- .../ServiceTypeSupport_impl.hpp | 6 ++++-- .../rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp | 10 +++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/MessageTypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/MessageTypeSupport_impl.hpp index 298e2485f..a21e20721 100644 --- a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/MessageTypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/MessageTypeSupport_impl.hpp @@ -50,8 +50,9 @@ MessageTypeSupport::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) { diff --git a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/ServiceTypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/ServiceTypeSupport_impl.hpp index b14959bfb..467703712 100644 --- a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/ServiceTypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/ServiceTypeSupport_impl.hpp @@ -49,8 +49,9 @@ RequestTypeSupport::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) { @@ -79,8 +80,9 @@ ResponseTypeSupport::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) { diff --git a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp index 0f83e0017..836b22214 100644 --- a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp @@ -66,6 +66,7 @@ TypeSupport::TypeSupport(const void * ros_type_support) { m_isGetKeyDefined = false; max_size_bound_ = false; + is_plain_ = false; } // C++ specialization @@ -829,9 +830,15 @@ size_t TypeSupport::calculateMaxSerializedSize( size_t array_size = 1; if (member->is_array_) { array_size = member->array_size_; + + // Whether it is unbounded. + if (0 == 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); } @@ -866,6 +873,7 @@ size_t TypeSupport::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) { From f4dde4df5d30b1a1518ddb0b5459814b5b80c9b9 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 17 Mar 2021 10:49:54 +0100 Subject: [PATCH 5/6] Linters. Signed-off-by: Miguel Company --- .../include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp index 836b22214..aa4dc500d 100644 --- a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp @@ -830,7 +830,7 @@ size_t TypeSupport::calculateMaxSerializedSize( size_t array_size = 1; if (member->is_array_) { array_size = member->array_size_; - + // Whether it is unbounded. if (0 == array_size) { this->max_size_bound_ = false; From f7f275cecb1c967919c0fbc8f3cf0f9d3a84af69 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 29 Mar 2021 07:07:33 +0200 Subject: [PATCH 6/6] Apply suggestion Signed-off-by: Miguel Company Co-authored-by: Michel Hidalgo --- .../include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp index aa4dc500d..68d74d26f 100644 --- a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp @@ -832,7 +832,7 @@ size_t TypeSupport::calculateMaxSerializedSize( array_size = member->array_size_; // Whether it is unbounded. - if (0 == array_size) { + if (0u == array_size) { this->max_size_bound_ = false; }