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

Fixing type support C/CPP mix on rmw_fastrtps_dynamic_cpp #350

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
6 changes: 3 additions & 3 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ namespace rmw_fastrtps_cpp
class TypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport
{
public:
size_t getEstimatedSerializedSize(const void * ros_message, const void * impl);
size_t getEstimatedSerializedSize(const void * ros_message, const void * impl) const override;

bool serializeROSmessage(
const void * ros_message, eprosima::fastcdr::Cdr & ser, const void * impl);
const void * ros_message, eprosima::fastcdr::Cdr & ser, const void * impl) const override;

bool deserializeROSmessage(
eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl);
eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override;

protected:
TypeSupport();
Expand Down
6 changes: 3 additions & 3 deletions rmw_fastrtps_cpp/src/type_support_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void TypeSupport::set_members(const message_type_support_callbacks_t * members)
m_typeSize = 4 + data_size;
}

size_t TypeSupport::getEstimatedSerializedSize(const void * ros_message, const void * impl)
size_t TypeSupport::getEstimatedSerializedSize(const void * ros_message, const void * impl) const
{
if (max_size_bound_) {
return m_typeSize;
Expand All @@ -63,7 +63,7 @@ size_t TypeSupport::getEstimatedSerializedSize(const void * ros_message, const v
}

bool TypeSupport::serializeROSmessage(
const void * ros_message, eprosima::fastcdr::Cdr & ser, const void * impl)
const void * ros_message, eprosima::fastcdr::Cdr & ser, const void * impl) const
{
assert(ros_message);
assert(impl);
Expand All @@ -83,7 +83,7 @@ bool TypeSupport::serializeROSmessage(
}

bool TypeSupport::deserializeROSmessage(
eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl)
eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const
{
assert(ros_message);
assert(impl);
Expand Down
2 changes: 2 additions & 0 deletions rmw_fastrtps_dynamic_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ add_library(rmw_fastrtps_dynamic_cpp
src/rmw_wait.cpp
src/rmw_wait_set.cpp
src/type_support_common.cpp
src/type_support_proxy.cpp
src/type_support_registry.cpp
src/serialization_format.cpp
)
target_link_libraries(rmw_fastrtps_dynamic_cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ template<typename MembersType>
class MessageTypeSupport : public TypeSupport<MembersType>
{
public:
explicit MessageTypeSupport(const MembersType * members);
MessageTypeSupport(const MembersType * members, const void * ros_type_support);
};

} // namespace rmw_fastrtps_dynamic_cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ namespace rmw_fastrtps_dynamic_cpp
{

template<typename MembersType>
MessageTypeSupport<MembersType>::MessageTypeSupport(const MembersType * members)
MessageTypeSupport<MembersType>::MessageTypeSupport(
const MembersType * members, const void * ros_type_support)
: TypeSupport<MembersType>(ros_type_support)
{
assert(members);
this->members_ = members;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,18 @@
namespace rmw_fastrtps_dynamic_cpp
{

template<typename MembersType>
class ServiceTypeSupport : public TypeSupport<MembersType>
{
protected:
ServiceTypeSupport();
};

template<typename ServiceMembersType, typename MessageMembersType>
class RequestTypeSupport : public ServiceTypeSupport<MessageMembersType>
class RequestTypeSupport : public TypeSupport<MessageMembersType>
{
public:
explicit RequestTypeSupport(const ServiceMembersType * members);
RequestTypeSupport(const ServiceMembersType * members, const void * ros_type_support);
};

template<typename ServiceMembersType, typename MessageMembersType>
class ResponseTypeSupport : public ServiceTypeSupport<MessageMembersType>
class ResponseTypeSupport : public TypeSupport<MessageMembersType>
{
public:
explicit ResponseTypeSupport(const ServiceMembersType * members);
ResponseTypeSupport(const ServiceMembersType * members, const void * ros_type_support);
};

} // namespace rmw_fastrtps_dynamic_cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@
namespace rmw_fastrtps_dynamic_cpp
{

template<typename MembersType>
ServiceTypeSupport<MembersType>::ServiceTypeSupport()
{
}

template<typename ServiceMembersType, typename MessageMembersType>
RequestTypeSupport<ServiceMembersType, MessageMembersType>::RequestTypeSupport(
const ServiceMembersType * members)
const ServiceMembersType * members, const void * ros_type_support)
: TypeSupport<MessageMembersType>(ros_type_support)
{
assert(members);
this->members_ = members->request_members_;
Expand Down Expand Up @@ -65,7 +61,8 @@ RequestTypeSupport<ServiceMembersType, MessageMembersType>::RequestTypeSupport(

template<typename ServiceMembersType, typename MessageMembersType>
ResponseTypeSupport<ServiceMembersType, MessageMembersType>::ResponseTypeSupport(
const ServiceMembersType * members)
const ServiceMembersType * members, const void * ros_type_support)
: TypeSupport<MessageMembersType>(ros_type_support)
{
assert(members);
this->members_ = members->response_members_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,35 +130,73 @@ struct StringHelper<rosidl_typesupport_introspection_cpp::MessageMembers>
}
};

class TypeSupportProxy : public rmw_fastrtps_shared_cpp::TypeSupport
{
public:
explicit TypeSupportProxy(rmw_fastrtps_shared_cpp::TypeSupport * inner_type);

size_t getEstimatedSerializedSize(const void * ros_message, const void * impl) const override;

bool serializeROSmessage(
const void * ros_message, eprosima::fastcdr::Cdr & ser, const void * impl) const override;

bool deserializeROSmessage(
eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override;
};

class BaseTypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport
{
public:
const void * ros_type_support() const
{
return ros_type_support_;
}

protected:
explicit BaseTypeSupport(const void * ros_type_support)
{
ros_type_support_ = ros_type_support;
}

private:
const void * ros_type_support_;
};

template<typename MembersType>
class TypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport
class TypeSupport : public BaseTypeSupport
{
public:
size_t getEstimatedSerializedSize(const void * ros_message, const void * impl);
size_t getEstimatedSerializedSize(const void * ros_message, const void * impl) const override;

bool serializeROSmessage(
const void * ros_message, eprosima::fastcdr::Cdr & ser, const void * impl);
const void * ros_message, eprosima::fastcdr::Cdr & ser, const void * impl) const override;

bool deserializeROSmessage(
eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl);
eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override;

protected:
TypeSupport();
explicit TypeSupport(const void * ros_type_support);

size_t calculateMaxSerializedSize(const MembersType * members, size_t current_alignment);

const MembersType * members_;

private:
size_t getEstimatedSerializedSize(
const MembersType * members, const void * ros_message, size_t current_alignment);
const MembersType * members,
const void * ros_message,
size_t current_alignment) const;

bool serializeROSmessage(
eprosima::fastcdr::Cdr & ser, const MembersType * members, const void * ros_message);
eprosima::fastcdr::Cdr & ser,
const MembersType * members,
const void * ros_message) const;

bool deserializeROSmessage(
eprosima::fastcdr::Cdr & deser, const MembersType * members, void * ros_message,
bool call_new);
eprosima::fastcdr::Cdr & deser,
const MembersType * members,
void * ros_message,
bool call_new) const;
};

} // namespace rmw_fastrtps_dynamic_cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ rosidl_generator_c__void__Sequence__fini(rosidl_generator_c__void__Sequence * se
}

template<typename MembersType>
TypeSupport<MembersType>::TypeSupport()
TypeSupport<MembersType>::TypeSupport(const void * ros_type_support)
: BaseTypeSupport(ros_type_support)
{
m_isGetKeyDefined = false;
max_size_bound_ = false;
Expand Down Expand Up @@ -372,7 +373,9 @@ size_t get_array_size_and_assign_field(

template<typename MembersType>
bool TypeSupport<MembersType>::serializeROSmessage(
eprosima::fastcdr::Cdr & ser, const MembersType * members, const void * ros_message)
eprosima::fastcdr::Cdr & ser,
const MembersType * members,
const void * ros_message) const
{
assert(members);
assert(ros_message);
Expand Down Expand Up @@ -630,7 +633,9 @@ size_t next_field_align_string<std::wstring>(

template<typename MembersType>
size_t TypeSupport<MembersType>::getEstimatedSerializedSize(
const MembersType * members, const void * ros_message, size_t current_alignment)
const MembersType * members,
const void * ros_message,
size_t current_alignment) const
{
assert(members);
assert(ros_message);
Expand Down Expand Up @@ -949,7 +954,10 @@ inline size_t get_submessage_array_deserialize(

template<typename MembersType>
bool TypeSupport<MembersType>::deserializeROSmessage(
eprosima::fastcdr::Cdr & deser, const MembersType * members, void * ros_message, bool call_new)
eprosima::fastcdr::Cdr & deser,
const MembersType * members,
void * ros_message,
bool call_new) const
{
assert(members);
assert(ros_message);
Expand Down Expand Up @@ -1117,21 +1125,21 @@ size_t TypeSupport<MembersType>::calculateMaxSerializedSize(

template<typename MembersType>
size_t TypeSupport<MembersType>::getEstimatedSerializedSize(
const void * ros_message, const void * impl)
const void * ros_message, const void * impl) const
{
if (max_size_bound_) {
return m_typeSize;
}

assert(ros_message);
assert(impl);
assert(members_);

// Encapsulation size
size_t ret_val = 4;

auto members = static_cast<const MembersType *>(impl);
if (members->member_count_ != 0) {
ret_val += TypeSupport::getEstimatedSerializedSize(members, ros_message, 0);
(void)impl;
if (members_->member_count_ != 0) {
ret_val += TypeSupport::getEstimatedSerializedSize(members_, ros_message, 0);
} else {
ret_val += 1;
}
Expand All @@ -1141,17 +1149,17 @@ size_t TypeSupport<MembersType>::getEstimatedSerializedSize(

template<typename MembersType>
bool TypeSupport<MembersType>::serializeROSmessage(
const void * ros_message, eprosima::fastcdr::Cdr & ser, const void * impl)
const void * ros_message, eprosima::fastcdr::Cdr & ser, const void * impl) const
{
assert(ros_message);
assert(impl);
assert(members_);

// Serialize encapsulation
ser.serialize_encapsulation();

auto members = static_cast<const MembersType *>(impl);
if (members->member_count_ != 0) {
TypeSupport::serializeROSmessage(ser, members, ros_message);
(void)impl;
if (members_->member_count_ != 0) {
TypeSupport::serializeROSmessage(ser, members_, ros_message);
} else {
ser << (uint8_t)0;
}
Expand All @@ -1161,17 +1169,17 @@ bool TypeSupport<MembersType>::serializeROSmessage(

template<typename MembersType>
bool TypeSupport<MembersType>::deserializeROSmessage(
eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl)
eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const
{
assert(ros_message);
assert(impl);
assert(members_);

// Deserialize encapsulation.
deser.read_encapsulation();

auto members = static_cast<const MembersType *>(impl);
if (members->member_count_ != 0) {
TypeSupport::deserializeROSmessage(deser, members, ros_message, false);
(void)impl;
if (members_->member_count_ != 0) {
TypeSupport::deserializeROSmessage(deser, members_, ros_message, false);
} else {
uint8_t dump = 0;
deser >> dump;
Expand Down
Loading