From 7c430989ed8c5cbea1ec9de13d619698264fa2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Fri, 14 Jun 2024 07:30:18 +0200 Subject: [PATCH] TypeObjectRegistry refactor (#139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refs #21045. Regenerated idl files Signed-off-by: Ricardo González Moreno * Refs #21045. Regenerated idl files Signed-off-by: Ricardo González Moreno --------- Signed-off-by: Ricardo González Moreno --- types/KeylessShapeTypePubSubTypes.cxx | 4 +- types/KeylessShapeTypePubSubTypes.h | 2 +- types/KeylessShapeTypeTypeObjectSupport.cxx | 272 ++++---------------- types/KeylessShapeTypeTypeObjectSupport.hpp | 11 +- types/ShapePubSubTypes.cxx | 4 +- types/ShapePubSubTypes.h | 2 +- types/ShapeTypeObjectSupport.cxx | 268 ++++--------------- types/ShapeTypeObjectSupport.hpp | 7 +- 8 files changed, 110 insertions(+), 460 deletions(-) diff --git a/types/KeylessShapeTypePubSubTypes.cxx b/types/KeylessShapeTypePubSubTypes.cxx index aea5f6a..781271a 100644 --- a/types/KeylessShapeTypePubSubTypes.cxx +++ b/types/KeylessShapeTypePubSubTypes.cxx @@ -221,9 +221,9 @@ namespace shapes_demo_typesupport { return true; } - void KeylessShapeTypePubSubType::register_type_object_representation() const + void KeylessShapeTypePubSubType::register_type_object_representation() { - register_KeylessShapeType_type_objects(); + register_KeylessShapeType_type_identifier(type_identifiers_); } } // namespace idl diff --git a/types/KeylessShapeTypePubSubTypes.h b/types/KeylessShapeTypePubSubTypes.h index 750ca45..c605b9a 100644 --- a/types/KeylessShapeTypePubSubTypes.h +++ b/types/KeylessShapeTypePubSubTypes.h @@ -93,7 +93,7 @@ namespace shapes_demo_typesupport void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() const override; + eProsima_user_DllExport void register_type_object_representation() override; #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override diff --git a/types/KeylessShapeTypeTypeObjectSupport.cxx b/types/KeylessShapeTypeTypeObjectSupport.cxx index 1f67a2b..dcf93c1 100644 --- a/types/KeylessShapeTypeTypeObjectSupport.cxx +++ b/types/KeylessShapeTypeTypeObjectSupport.cxx @@ -38,28 +38,21 @@ using namespace eprosima::fastdds::dds::xtypes; -void register_KeylessShapeType_type_objects() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeIdentifier type_id; - shapes_demo_typesupport::idl::register_shapes_demo_typesupport_idl_KeylessShapeType_type_identifier(type_id); - - }); -} - namespace shapes_demo_typesupport { namespace idl { // TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_shapes_demo_typesupport_idl_KeylessShapeType_type_identifier( - TypeIdentifier& type_id) +void register_KeylessShapeType_type_identifier( + TypeIdentifierPair& type_ids_KeylessShapeType) { + + ReturnCode_t return_code_KeylessShapeType {eprosima::fastdds::dds::RETCODE_OK}; + return_code_KeylessShapeType = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "shapes_demo_typesupport::idl::KeylessShapeType", type_ids_KeylessShapeType); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_KeylessShapeType) { - StructTypeFlag struct_flags_KeylessShapeType = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, + StructTypeFlag struct_flags_KeylessShapeType = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, false, false); - ReturnCode_t return_code_KeylessShapeType; - TypeIdentifierPair type_ids_KeylessShapeType; QualifiedTypeName type_name_KeylessShapeType = "shapes_demo_typesupport::idl::KeylessShapeType"; eprosima::fastcdr::optional type_ann_builtin_KeylessShapeType; eprosima::fastcdr::optional ann_custom_KeylessShapeType; @@ -68,79 +61,34 @@ void register_shapes_demo_typesupport_idl_KeylessShapeType_type_identifier( header_KeylessShapeType = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_KeylessShapeType); CompleteStructMemberSeq member_seq_KeylessShapeType; { - return_code_KeylessShapeType = + TypeIdentifierPair type_ids_color; + ReturnCode_t return_code_color {eprosima::fastdds::dds::RETCODE_OK}; + return_code_color = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_KeylessShapeType); + "anonymous_string_unbounded", type_ids_color); - if (return_code_KeylessShapeType != eprosima::fastdds::dds::RETCODE_OK) + if (eprosima::fastdds::dds::RETCODE_OK != return_code_color) { { SBound bound = 0; StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, - "anonymous_string_unbounded")) + "anonymous_string_unbounded", type_ids_color)) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); } } - return_code_KeylessShapeType = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_KeylessShapeType); - if (return_code_KeylessShapeType != eprosima::fastdds::dds::RETCODE_OK) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_unbounded: Given String TypeIdentifier unknown to TypeObjectRegistry."); - type_id = TypeIdentifier(); - return; - } } - StructMemberFlag member_flags_color = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, + StructMemberFlag member_flags_color = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, false, false, false, false); - CommonStructMember common_color; MemberId member_id_color = 0x00000000; - if (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1()._d() || TK_NONE == type_ids_KeylessShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_ldefn().key_identifier()->_d()))) + bool common_color_ec {false}; + CommonStructMember common_color {TypeObjectUtils::build_common_struct_member(member_id_color, member_flags_color, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_color, common_color_ec))}; + if (!common_color_ec) { - common_color = TypeObjectUtils::build_common_struct_member(member_id_color, member_flags_color, type_ids_KeylessShapeType.type_identifier1()); - } - else if (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_ldefn().key_identifier()->_d()))) - { - common_color = TypeObjectUtils::build_common_struct_member(member_id_color, member_flags_color, type_ids_KeylessShapeType.type_identifier2()); - } - else - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Structure color member TypeIdentifier inconsistent."); - type_id = TypeIdentifier(); + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure color member TypeIdentifier inconsistent."); return; } MemberName name_color = "color"; @@ -151,62 +99,26 @@ void register_shapes_demo_typesupport_idl_KeylessShapeType_type_identifier( TypeObjectUtils::add_complete_struct_member(member_seq_KeylessShapeType, member_color); } { - return_code_KeylessShapeType = + TypeIdentifierPair type_ids_x; + ReturnCode_t return_code_x {eprosima::fastdds::dds::RETCODE_OK}; + return_code_x = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_int32_t", type_ids_KeylessShapeType); + "_int32_t", type_ids_x); - if (return_code_KeylessShapeType != eprosima::fastdds::dds::RETCODE_OK) + if (eprosima::fastdds::dds::RETCODE_OK != return_code_x) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "x Structure member TypeIdentifier unknown to TypeObjectRegistry."); - type_id = TypeIdentifier(); return; } - StructMemberFlag member_flags_x = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, + StructMemberFlag member_flags_x = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, false, false, false, false); - CommonStructMember common_x; MemberId member_id_x = 0x00000001; - if (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1()._d() || TK_NONE == type_ids_KeylessShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_ldefn().key_identifier()->_d()))) - { - common_x = TypeObjectUtils::build_common_struct_member(member_id_x, member_flags_x, type_ids_KeylessShapeType.type_identifier1()); - } - else if (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_ldefn().key_identifier()->_d()))) + bool common_x_ec {false}; + CommonStructMember common_x {TypeObjectUtils::build_common_struct_member(member_id_x, member_flags_x, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_x, common_x_ec))}; + if (!common_x_ec) { - common_x = TypeObjectUtils::build_common_struct_member(member_id_x, member_flags_x, type_ids_KeylessShapeType.type_identifier2()); - } - else - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Structure x member TypeIdentifier inconsistent."); - type_id = TypeIdentifier(); + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure x member TypeIdentifier inconsistent."); return; } MemberName name_x = "x"; @@ -217,62 +129,26 @@ void register_shapes_demo_typesupport_idl_KeylessShapeType_type_identifier( TypeObjectUtils::add_complete_struct_member(member_seq_KeylessShapeType, member_x); } { - return_code_KeylessShapeType = + TypeIdentifierPair type_ids_y; + ReturnCode_t return_code_y {eprosima::fastdds::dds::RETCODE_OK}; + return_code_y = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_int32_t", type_ids_KeylessShapeType); + "_int32_t", type_ids_y); - if (return_code_KeylessShapeType != eprosima::fastdds::dds::RETCODE_OK) + if (eprosima::fastdds::dds::RETCODE_OK != return_code_y) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "y Structure member TypeIdentifier unknown to TypeObjectRegistry."); - type_id = TypeIdentifier(); return; } - StructMemberFlag member_flags_y = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, + StructMemberFlag member_flags_y = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, false, false, false, false); - CommonStructMember common_y; MemberId member_id_y = 0x00000002; - if (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1()._d() || TK_NONE == type_ids_KeylessShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_ldefn().key_identifier()->_d()))) - { - common_y = TypeObjectUtils::build_common_struct_member(member_id_y, member_flags_y, type_ids_KeylessShapeType.type_identifier1()); - } - else if (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_ldefn().key_identifier()->_d()))) + bool common_y_ec {false}; + CommonStructMember common_y {TypeObjectUtils::build_common_struct_member(member_id_y, member_flags_y, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_y, common_y_ec))}; + if (!common_y_ec) { - common_y = TypeObjectUtils::build_common_struct_member(member_id_y, member_flags_y, type_ids_KeylessShapeType.type_identifier2()); - } - else - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Structure y member TypeIdentifier inconsistent."); - type_id = TypeIdentifier(); + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure y member TypeIdentifier inconsistent."); return; } MemberName name_y = "y"; @@ -283,62 +159,26 @@ void register_shapes_demo_typesupport_idl_KeylessShapeType_type_identifier( TypeObjectUtils::add_complete_struct_member(member_seq_KeylessShapeType, member_y); } { - return_code_KeylessShapeType = + TypeIdentifierPair type_ids_shapesize; + ReturnCode_t return_code_shapesize {eprosima::fastdds::dds::RETCODE_OK}; + return_code_shapesize = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_int32_t", type_ids_KeylessShapeType); + "_int32_t", type_ids_shapesize); - if (return_code_KeylessShapeType != eprosima::fastdds::dds::RETCODE_OK) + if (eprosima::fastdds::dds::RETCODE_OK != return_code_shapesize) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "shapesize Structure member TypeIdentifier unknown to TypeObjectRegistry."); - type_id = TypeIdentifier(); return; } - StructMemberFlag member_flags_shapesize = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, + StructMemberFlag member_flags_shapesize = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, false, false, false, false); - CommonStructMember common_shapesize; MemberId member_id_shapesize = 0x00000003; - if (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1()._d() || TK_NONE == type_ids_KeylessShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_KeylessShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_KeylessShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier1().map_ldefn().key_identifier()->_d()))) + bool common_shapesize_ec {false}; + CommonStructMember common_shapesize {TypeObjectUtils::build_common_struct_member(member_id_shapesize, member_flags_shapesize, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_shapesize, common_shapesize_ec))}; + if (!common_shapesize_ec) { - common_shapesize = TypeObjectUtils::build_common_struct_member(member_id_shapesize, member_flags_shapesize, type_ids_KeylessShapeType.type_identifier1()); - } - else if (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_KeylessShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_KeylessShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_KeylessShapeType.type_identifier2().map_ldefn().key_identifier()->_d()))) - { - common_shapesize = TypeObjectUtils::build_common_struct_member(member_id_shapesize, member_flags_shapesize, type_ids_KeylessShapeType.type_identifier2()); - } - else - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Structure shapesize member TypeIdentifier inconsistent."); - type_id = TypeIdentifier(); + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure shapesize member TypeIdentifier inconsistent."); return; } MemberName name_shapesize = "shapesize"; @@ -350,21 +190,11 @@ void register_shapes_demo_typesupport_idl_KeylessShapeType_type_identifier( } CompleteStructType struct_type_KeylessShapeType = TypeObjectUtils::build_complete_struct_type(struct_flags_KeylessShapeType, header_KeylessShapeType, member_seq_KeylessShapeType); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_KeylessShapeType, type_name_KeylessShapeType.to_string(), type_id)) + TypeObjectUtils::build_and_register_struct_type_object(struct_type_KeylessShapeType, type_name_KeylessShapeType.to_string(), type_ids_KeylessShapeType)) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "shapes_demo_typesupport::idl::KeylessShapeType already registered in TypeObjectRegistry for a different type."); } - return_code_KeylessShapeType = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "shapes_demo_typesupport::idl::KeylessShapeType", type_ids_KeylessShapeType); - if (return_code_KeylessShapeType != eprosima::fastdds::dds::RETCODE_OK) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "shapes_demo_typesupport::idl::KeylessShapeType: Given Struct TypeIdentifier unknown to TypeObjectRegistry."); - type_id = TypeIdentifier(); - return; - } } } diff --git a/types/KeylessShapeTypeTypeObjectSupport.hpp b/types/KeylessShapeTypeTypeObjectSupport.hpp index c4952f6..f50e6f7 100644 --- a/types/KeylessShapeTypeTypeObjectSupport.hpp +++ b/types/KeylessShapeTypeTypeObjectSupport.hpp @@ -35,17 +35,12 @@ #define eProsima_user_DllExport #endif // _WIN32 -/** - * @brief Register every TypeObject representation defined in the IDL file in Fast DDS TypeObjectRegistry. - */ -eProsima_user_DllExport void register_KeylessShapeType_type_objects(); - #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC namespace shapes_demo_typesupport { namespace idl { /** - * @brief Register shapes_demo_typesupport_idl_KeylessShapeType related TypeIdentifier. + * @brief Register KeylessShapeType related TypeIdentifier. * Fully-descriptive TypeIdentifiers are directly registered. * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is * indirectly registered as well. @@ -54,8 +49,8 @@ namespace idl { * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. * Invalid TypeIdentifier is returned in case of error. */ -eProsima_user_DllExport void register_shapes_demo_typesupport_idl_KeylessShapeType_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id); +eProsima_user_DllExport void register_KeylessShapeType_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); } // namespace idl diff --git a/types/ShapePubSubTypes.cxx b/types/ShapePubSubTypes.cxx index b5ccda8..4e1a661 100644 --- a/types/ShapePubSubTypes.cxx +++ b/types/ShapePubSubTypes.cxx @@ -219,9 +219,9 @@ bool ShapeTypePubSubType::getKey( return true; } -void ShapeTypePubSubType::register_type_object_representation() const +void ShapeTypePubSubType::register_type_object_representation() { - register_Shape_type_objects(); + register_ShapeType_type_identifier(type_identifiers_); } diff --git a/types/ShapePubSubTypes.h b/types/ShapePubSubTypes.h index bb53c1c..ac92938 100644 --- a/types/ShapePubSubTypes.h +++ b/types/ShapePubSubTypes.h @@ -89,7 +89,7 @@ class ShapeTypePubSubType : public eprosima::fastdds::dds::TopicDataType void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() const override; + eProsima_user_DllExport void register_type_object_representation() override; #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override diff --git a/types/ShapeTypeObjectSupport.cxx b/types/ShapeTypeObjectSupport.cxx index f04b9c5..a97b597 100644 --- a/types/ShapeTypeObjectSupport.cxx +++ b/types/ShapeTypeObjectSupport.cxx @@ -38,26 +38,19 @@ using namespace eprosima::fastdds::dds::xtypes; -void register_Shape_type_objects() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeIdentifier type_id; - register_ShapeType_type_identifier(type_id); - - }); -} - // TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method void register_ShapeType_type_identifier( - TypeIdentifier& type_id) + TypeIdentifierPair& type_ids_ShapeType) { + + ReturnCode_t return_code_ShapeType {eprosima::fastdds::dds::RETCODE_OK}; + return_code_ShapeType = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "ShapeType", type_ids_ShapeType); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_ShapeType) { StructTypeFlag struct_flags_ShapeType = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, false, false); - ReturnCode_t return_code_ShapeType; - TypeIdentifierPair type_ids_ShapeType; QualifiedTypeName type_name_ShapeType = "ShapeType"; eprosima::fastcdr::optional type_ann_builtin_ShapeType; eprosima::fastcdr::optional ann_custom_ShapeType; @@ -73,79 +66,34 @@ void register_ShapeType_type_identifier( header_ShapeType = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_ShapeType); CompleteStructMemberSeq member_seq_ShapeType; { - return_code_ShapeType = + TypeIdentifierPair type_ids_color; + ReturnCode_t return_code_color {eprosima::fastdds::dds::RETCODE_OK}; + return_code_color = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_ShapeType); + "anonymous_string_unbounded", type_ids_color); - if (return_code_ShapeType != eprosima::fastdds::dds::RETCODE_OK) + if (eprosima::fastdds::dds::RETCODE_OK != return_code_color) { { SBound bound = 0; StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, - "anonymous_string_unbounded")) + "anonymous_string_unbounded", type_ids_color)) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); } } - return_code_ShapeType = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_ShapeType); - if (return_code_ShapeType != eprosima::fastdds::dds::RETCODE_OK) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_unbounded: Given String TypeIdentifier unknown to TypeObjectRegistry."); - type_id = TypeIdentifier(); - return; - } } - StructMemberFlag member_flags_color = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, + StructMemberFlag member_flags_color = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, false, false, true, false); - CommonStructMember common_color; MemberId member_id_color = 0x00000000; - if (EK_COMPLETE == type_ids_ShapeType.type_identifier1()._d() || TK_NONE == type_ids_ShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_ShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_ShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_ldefn().key_identifier()->_d()))) + bool common_color_ec {false}; + CommonStructMember common_color {TypeObjectUtils::build_common_struct_member(member_id_color, member_flags_color, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_color, common_color_ec))}; + if (!common_color_ec) { - common_color = TypeObjectUtils::build_common_struct_member(member_id_color, member_flags_color, type_ids_ShapeType.type_identifier1()); - } - else if (EK_COMPLETE == type_ids_ShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_ShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_ShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_ldefn().key_identifier()->_d()))) - { - common_color = TypeObjectUtils::build_common_struct_member(member_id_color, member_flags_color, type_ids_ShapeType.type_identifier2()); - } - else - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Structure color member TypeIdentifier inconsistent."); - type_id = TypeIdentifier(); + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure color member TypeIdentifier inconsistent."); return; } MemberName name_color = "color"; @@ -169,62 +117,26 @@ void register_ShapeType_type_identifier( TypeObjectUtils::add_complete_struct_member(member_seq_ShapeType, member_color); } { - return_code_ShapeType = + TypeIdentifierPair type_ids_x; + ReturnCode_t return_code_x {eprosima::fastdds::dds::RETCODE_OK}; + return_code_x = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_int32_t", type_ids_ShapeType); + "_int32_t", type_ids_x); - if (return_code_ShapeType != eprosima::fastdds::dds::RETCODE_OK) + if (eprosima::fastdds::dds::RETCODE_OK != return_code_x) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "x Structure member TypeIdentifier unknown to TypeObjectRegistry."); - type_id = TypeIdentifier(); return; } - StructMemberFlag member_flags_x = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, + StructMemberFlag member_flags_x = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, false, false, false, false); - CommonStructMember common_x; MemberId member_id_x = 0x00000001; - if (EK_COMPLETE == type_ids_ShapeType.type_identifier1()._d() || TK_NONE == type_ids_ShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_ShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_ShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_ldefn().key_identifier()->_d()))) - { - common_x = TypeObjectUtils::build_common_struct_member(member_id_x, member_flags_x, type_ids_ShapeType.type_identifier1()); - } - else if (EK_COMPLETE == type_ids_ShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_ShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_ShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_ldefn().key_identifier()->_d()))) + bool common_x_ec {false}; + CommonStructMember common_x {TypeObjectUtils::build_common_struct_member(member_id_x, member_flags_x, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_x, common_x_ec))}; + if (!common_x_ec) { - common_x = TypeObjectUtils::build_common_struct_member(member_id_x, member_flags_x, type_ids_ShapeType.type_identifier2()); - } - else - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Structure x member TypeIdentifier inconsistent."); - type_id = TypeIdentifier(); + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure x member TypeIdentifier inconsistent."); return; } MemberName name_x = "x"; @@ -235,62 +147,26 @@ void register_ShapeType_type_identifier( TypeObjectUtils::add_complete_struct_member(member_seq_ShapeType, member_x); } { - return_code_ShapeType = + TypeIdentifierPair type_ids_y; + ReturnCode_t return_code_y {eprosima::fastdds::dds::RETCODE_OK}; + return_code_y = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_int32_t", type_ids_ShapeType); + "_int32_t", type_ids_y); - if (return_code_ShapeType != eprosima::fastdds::dds::RETCODE_OK) + if (eprosima::fastdds::dds::RETCODE_OK != return_code_y) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "y Structure member TypeIdentifier unknown to TypeObjectRegistry."); - type_id = TypeIdentifier(); return; } - StructMemberFlag member_flags_y = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, + StructMemberFlag member_flags_y = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, false, false, false, false); - CommonStructMember common_y; MemberId member_id_y = 0x00000002; - if (EK_COMPLETE == type_ids_ShapeType.type_identifier1()._d() || TK_NONE == type_ids_ShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_ShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_ShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_ldefn().key_identifier()->_d()))) - { - common_y = TypeObjectUtils::build_common_struct_member(member_id_y, member_flags_y, type_ids_ShapeType.type_identifier1()); - } - else if (EK_COMPLETE == type_ids_ShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_ShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_ShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_ldefn().key_identifier()->_d()))) + bool common_y_ec {false}; + CommonStructMember common_y {TypeObjectUtils::build_common_struct_member(member_id_y, member_flags_y, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_y, common_y_ec))}; + if (!common_y_ec) { - common_y = TypeObjectUtils::build_common_struct_member(member_id_y, member_flags_y, type_ids_ShapeType.type_identifier2()); - } - else - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Structure y member TypeIdentifier inconsistent."); - type_id = TypeIdentifier(); + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure y member TypeIdentifier inconsistent."); return; } MemberName name_y = "y"; @@ -301,62 +177,26 @@ void register_ShapeType_type_identifier( TypeObjectUtils::add_complete_struct_member(member_seq_ShapeType, member_y); } { - return_code_ShapeType = + TypeIdentifierPair type_ids_shapesize; + ReturnCode_t return_code_shapesize {eprosima::fastdds::dds::RETCODE_OK}; + return_code_shapesize = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_int32_t", type_ids_ShapeType); + "_int32_t", type_ids_shapesize); - if (return_code_ShapeType != eprosima::fastdds::dds::RETCODE_OK) + if (eprosima::fastdds::dds::RETCODE_OK != return_code_shapesize) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "shapesize Structure member TypeIdentifier unknown to TypeObjectRegistry."); - type_id = TypeIdentifier(); return; } - StructMemberFlag member_flags_shapesize = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, + StructMemberFlag member_flags_shapesize = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, false, false, false, false); - CommonStructMember common_shapesize; MemberId member_id_shapesize = 0x00000003; - if (EK_COMPLETE == type_ids_ShapeType.type_identifier1()._d() || TK_NONE == type_ids_ShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_ShapeType.type_identifier1()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier1().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_ShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_ShapeType.type_identifier1()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier1().map_ldefn().key_identifier()->_d()))) + bool common_shapesize_ec {false}; + CommonStructMember common_shapesize {TypeObjectUtils::build_common_struct_member(member_id_shapesize, member_flags_shapesize, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_shapesize, common_shapesize_ec))}; + if (!common_shapesize_ec) { - common_shapesize = TypeObjectUtils::build_common_struct_member(member_id_shapesize, member_flags_shapesize, type_ids_ShapeType.type_identifier1()); - } - else if (EK_COMPLETE == type_ids_ShapeType.type_identifier2()._d() || - (TI_PLAIN_SEQUENCE_SMALL == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().seq_sdefn().header().equiv_kind()) || - (TI_PLAIN_SEQUENCE_LARGE == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().seq_ldefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_SMALL == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().array_sdefn().header().equiv_kind()) || - (TI_PLAIN_ARRAY_LARGE == type_ids_ShapeType.type_identifier2()._d() && - EK_COMPLETE == type_ids_ShapeType.type_identifier2().array_ldefn().header().equiv_kind()) || - (TI_PLAIN_MAP_SMALL == type_ids_ShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_sdefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_sdefn().key_identifier()->_d())) || - (TI_PLAIN_MAP_LARGE == type_ids_ShapeType.type_identifier2()._d() && - (EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_ldefn().header().equiv_kind() || - EK_COMPLETE == type_ids_ShapeType.type_identifier2().map_ldefn().key_identifier()->_d()))) - { - common_shapesize = TypeObjectUtils::build_common_struct_member(member_id_shapesize, member_flags_shapesize, type_ids_ShapeType.type_identifier2()); - } - else - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Structure shapesize member TypeIdentifier inconsistent."); - type_id = TypeIdentifier(); + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure shapesize member TypeIdentifier inconsistent."); return; } MemberName name_shapesize = "shapesize"; @@ -368,21 +208,11 @@ void register_ShapeType_type_identifier( } CompleteStructType struct_type_ShapeType = TypeObjectUtils::build_complete_struct_type(struct_flags_ShapeType, header_ShapeType, member_seq_ShapeType); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_ShapeType, type_name_ShapeType.to_string(), type_id)) + TypeObjectUtils::build_and_register_struct_type_object(struct_type_ShapeType, type_name_ShapeType.to_string(), type_ids_ShapeType)) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "ShapeType already registered in TypeObjectRegistry for a different type."); } - return_code_ShapeType = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "ShapeType", type_ids_ShapeType); - if (return_code_ShapeType != eprosima::fastdds::dds::RETCODE_OK) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "ShapeType: Given Struct TypeIdentifier unknown to TypeObjectRegistry."); - type_id = TypeIdentifier(); - return; - } } } diff --git a/types/ShapeTypeObjectSupport.hpp b/types/ShapeTypeObjectSupport.hpp index 1896f0e..e330030 100644 --- a/types/ShapeTypeObjectSupport.hpp +++ b/types/ShapeTypeObjectSupport.hpp @@ -35,11 +35,6 @@ #define eProsima_user_DllExport #endif // _WIN32 -/** - * @brief Register every TypeObject representation defined in the IDL file in Fast DDS TypeObjectRegistry. - */ -eProsima_user_DllExport void register_Shape_type_objects(); - #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** @@ -53,7 +48,7 @@ eProsima_user_DllExport void register_Shape_type_objects(); * Invalid TypeIdentifier is returned in case of error. */ eProsima_user_DllExport void register_ShapeType_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id); + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC