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

TypeObjectRegistry refactor [21132] #4874

Merged
merged 22 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
edf5472
Refs #21044. Register individual structure
richiware May 17, 2024
36b2f6f
Refs #21044. Intermediate commit
richiware May 23, 2024
5eb79cd
Refs #21044. Apply suggestions from Lucia
richiware May 23, 2024
d6559a5
Refs #21044. Fix
richiware May 23, 2024
1a5ac93
Refs #21044. Regeneration of code
richiware May 27, 2024
996fdeb
Refs #21044. Fix
richiware May 27, 2024
d8a7d18
Refs #21044. Regeneration of code
richiware May 27, 2024
b372fa2
Refs #21044. Remove TODO
richiware May 30, 2024
df68a7b
Refs #21044. Fix warning on Windows
richiware May 30, 2024
142b27c
Refs #21044. Fix warning on mac and failed tests.
richiware May 31, 2024
12274f1
Refs #21044. Fix statistics tests
richiware May 31, 2024
97e9455
Refs #21044. Fix statistics tests and other things
richiware Jun 4, 2024
a59b641
Refs #21044. Fix doxygen
richiware Jun 5, 2024
2210c37
Refs #21044. More TryConstructKind standard
richiware Jun 6, 2024
678943d
Refs #21044. More ExtensibilityKind standard
richiware Jun 6, 2024
98a6ca5
Refs #21044. Apply suggestions
richiware Jun 10, 2024
9ab3f61
Refs #21044. Fix building minimal for remote coplete typeobject
richiware Jun 10, 2024
4dcb300
Refs #21044. Add and fixes for test BasicAnnotationsTest
richiware Jun 11, 2024
b80465d
Refs #21044. Add test UnionSeveralFields
richiware Jun 11, 2024
18f00e1
Refs #21044. Fix compilation
richiware Jun 11, 2024
0629dd9
Refs #21044. Fix compilation after rebase
richiware Jun 12, 2024
56b31e2
Refs #21044. Fix typelookupservice generating minimal type objects
richiware Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions examples/cpp/configuration/ConfigurationPubSubTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ bool ConfigurationPubSubType::getKey(
return true;
}

void ConfigurationPubSubType::register_type_object_representation() const
void ConfigurationPubSubType::register_type_object_representation()
{
register_Configuration_type_objects();
register_Configuration_type_identifier(type_identifiers_);
}


Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/configuration/ConfigurationPubSubTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ConfigurationPubSubType : 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
Expand Down
331 changes: 56 additions & 275 deletions examples/cpp/configuration/ConfigurationTypeObjectSupport.cxx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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_Configuration_type_objects();

#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

/**
Expand All @@ -53,7 +48,7 @@ eProsima_user_DllExport void register_Configuration_type_objects();
* Invalid TypeIdentifier is returned in case of error.
*/
eProsima_user_DllExport void register_Configuration_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids);


#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
Expand Down
4 changes: 2 additions & 2 deletions examples/cpp/custom_payload_pool/HelloWorldPubSubTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ bool HelloWorldPubSubType::getKey(
return true;
}

void HelloWorldPubSubType::register_type_object_representation() const
void HelloWorldPubSubType::register_type_object_representation()
{
register_HelloWorld_type_objects();
register_HelloWorld_type_identifier(type_identifiers_);
}


Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/custom_payload_pool/HelloWorldPubSubTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class HelloWorldPubSubType : 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
Expand Down
156 changes: 29 additions & 127 deletions examples/cpp/custom_payload_pool/HelloWorldTypeObjectSupport.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,19 @@

using namespace eprosima::fastdds::dds::xtypes;

void register_HelloWorld_type_objects()
{
static std::once_flag once_flag;
std::call_once(once_flag, []()
{
TypeIdentifier type_id;
register_HelloWorld_type_identifier(type_id);

});
}

// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
void register_HelloWorld_type_identifier(
TypeIdentifier& type_id)
TypeIdentifierPair& type_ids_HelloWorld)
{

ReturnCode_t return_code_HelloWorld {eprosima::fastdds::dds::RETCODE_OK};
return_code_HelloWorld =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"HelloWorld", type_ids_HelloWorld);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloWorld)
{
StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE,
false, false);
ReturnCode_t return_code_HelloWorld;
TypeIdentifierPair type_ids_HelloWorld;
QualifiedTypeName type_name_HelloWorld = "HelloWorld";
eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_HelloWorld;
eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_HelloWorld;
Expand All @@ -73,62 +66,26 @@ void register_HelloWorld_type_identifier(
header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld);
CompleteStructMemberSeq member_seq_HelloWorld;
{
return_code_HelloWorld =
TypeIdentifierPair type_ids_index;
ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK};
return_code_index =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"_uint32_t", type_ids_HelloWorld);
"_uint32_t", type_ids_index);

if (return_code_HelloWorld != eprosima::fastdds::dds::RETCODE_OK)
if (eprosima::fastdds::dds::RETCODE_OK != return_code_index)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"index Structure member TypeIdentifier unknown to TypeObjectRegistry.");
type_id = TypeIdentifier();
return;
}
StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED,
StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
false, false, false, false);
CommonStructMember common_index;
MemberId member_id_index = 0x00000000;
if (EK_COMPLETE == type_ids_HelloWorld.type_identifier1()._d() || TK_NONE == type_ids_HelloWorld.type_identifier2()._d() ||
(TI_PLAIN_SEQUENCE_SMALL == type_ids_HelloWorld.type_identifier1()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().seq_sdefn().header().equiv_kind()) ||
(TI_PLAIN_SEQUENCE_LARGE == type_ids_HelloWorld.type_identifier1()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().seq_ldefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_SMALL == type_ids_HelloWorld.type_identifier1()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().array_sdefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_LARGE == type_ids_HelloWorld.type_identifier1()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().array_ldefn().header().equiv_kind()) ||
(TI_PLAIN_MAP_SMALL == type_ids_HelloWorld.type_identifier1()._d() &&
(EK_COMPLETE == type_ids_HelloWorld.type_identifier1().map_sdefn().header().equiv_kind() ||
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().map_sdefn().key_identifier()->_d())) ||
(TI_PLAIN_MAP_LARGE == type_ids_HelloWorld.type_identifier1()._d() &&
(EK_COMPLETE == type_ids_HelloWorld.type_identifier1().map_ldefn().header().equiv_kind() ||
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().map_ldefn().key_identifier()->_d())))
bool common_index_ec {false};
CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))};
if (!common_index_ec)
{
common_index = TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, type_ids_HelloWorld.type_identifier1());
}
else if (EK_COMPLETE == type_ids_HelloWorld.type_identifier2()._d() ||
(TI_PLAIN_SEQUENCE_SMALL == type_ids_HelloWorld.type_identifier2()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().seq_sdefn().header().equiv_kind()) ||
(TI_PLAIN_SEQUENCE_LARGE == type_ids_HelloWorld.type_identifier2()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().seq_ldefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_SMALL == type_ids_HelloWorld.type_identifier2()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().array_sdefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_LARGE == type_ids_HelloWorld.type_identifier2()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().array_ldefn().header().equiv_kind()) ||
(TI_PLAIN_MAP_SMALL == type_ids_HelloWorld.type_identifier2()._d() &&
(EK_COMPLETE == type_ids_HelloWorld.type_identifier2().map_sdefn().header().equiv_kind() ||
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().map_sdefn().key_identifier()->_d())) ||
(TI_PLAIN_MAP_LARGE == type_ids_HelloWorld.type_identifier2()._d() &&
(EK_COMPLETE == type_ids_HelloWorld.type_identifier2().map_ldefn().header().equiv_kind() ||
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().map_ldefn().key_identifier()->_d())))
{
common_index = TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, type_ids_HelloWorld.type_identifier2());
}
else
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"Structure index member TypeIdentifier inconsistent.");
type_id = TypeIdentifier();
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent.");
return;
}
MemberName name_index = "index";
Expand All @@ -139,79 +96,34 @@ void register_HelloWorld_type_identifier(
TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index);
}
{
return_code_HelloWorld =
TypeIdentifierPair type_ids_message;
ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK};
return_code_message =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_string_unbounded", type_ids_HelloWorld);
"anonymous_string_unbounded", type_ids_message);

if (return_code_HelloWorld != eprosima::fastdds::dds::RETCODE_OK)
if (eprosima::fastdds::dds::RETCODE_OK != return_code_message)
{
{
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_message))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
return_code_HelloWorld =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_string_unbounded", type_ids_HelloWorld);
if (return_code_HelloWorld != 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_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED,
StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
false, false, false, false);
CommonStructMember common_message;
MemberId member_id_message = 0x00000001;
if (EK_COMPLETE == type_ids_HelloWorld.type_identifier1()._d() || TK_NONE == type_ids_HelloWorld.type_identifier2()._d() ||
(TI_PLAIN_SEQUENCE_SMALL == type_ids_HelloWorld.type_identifier1()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().seq_sdefn().header().equiv_kind()) ||
(TI_PLAIN_SEQUENCE_LARGE == type_ids_HelloWorld.type_identifier1()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().seq_ldefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_SMALL == type_ids_HelloWorld.type_identifier1()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().array_sdefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_LARGE == type_ids_HelloWorld.type_identifier1()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().array_ldefn().header().equiv_kind()) ||
(TI_PLAIN_MAP_SMALL == type_ids_HelloWorld.type_identifier1()._d() &&
(EK_COMPLETE == type_ids_HelloWorld.type_identifier1().map_sdefn().header().equiv_kind() ||
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().map_sdefn().key_identifier()->_d())) ||
(TI_PLAIN_MAP_LARGE == type_ids_HelloWorld.type_identifier1()._d() &&
(EK_COMPLETE == type_ids_HelloWorld.type_identifier1().map_ldefn().header().equiv_kind() ||
EK_COMPLETE == type_ids_HelloWorld.type_identifier1().map_ldefn().key_identifier()->_d())))
{
common_message = TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, type_ids_HelloWorld.type_identifier1());
}
else if (EK_COMPLETE == type_ids_HelloWorld.type_identifier2()._d() ||
(TI_PLAIN_SEQUENCE_SMALL == type_ids_HelloWorld.type_identifier2()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().seq_sdefn().header().equiv_kind()) ||
(TI_PLAIN_SEQUENCE_LARGE == type_ids_HelloWorld.type_identifier2()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().seq_ldefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_SMALL == type_ids_HelloWorld.type_identifier2()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().array_sdefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_LARGE == type_ids_HelloWorld.type_identifier2()._d() &&
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().array_ldefn().header().equiv_kind()) ||
(TI_PLAIN_MAP_SMALL == type_ids_HelloWorld.type_identifier2()._d() &&
(EK_COMPLETE == type_ids_HelloWorld.type_identifier2().map_sdefn().header().equiv_kind() ||
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().map_sdefn().key_identifier()->_d())) ||
(TI_PLAIN_MAP_LARGE == type_ids_HelloWorld.type_identifier2()._d() &&
(EK_COMPLETE == type_ids_HelloWorld.type_identifier2().map_ldefn().header().equiv_kind() ||
EK_COMPLETE == type_ids_HelloWorld.type_identifier2().map_ldefn().key_identifier()->_d())))
{
common_message = TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, type_ids_HelloWorld.type_identifier2());
}
else
bool common_message_ec {false};
CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))};
if (!common_message_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"Structure message member TypeIdentifier inconsistent.");
type_id = TypeIdentifier();
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent.");
return;
}
MemberName name_message = "message";
Expand All @@ -223,21 +135,11 @@ void register_HelloWorld_type_identifier(
}
CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_id))
TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_ids_HelloWorld))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"HelloWorld already registered in TypeObjectRegistry for a different type.");
}
return_code_HelloWorld =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"HelloWorld", type_ids_HelloWorld);
if (return_code_HelloWorld != eprosima::fastdds::dds::RETCODE_OK)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"HelloWorld: Given Struct TypeIdentifier unknown to TypeObjectRegistry.");
type_id = TypeIdentifier();
return;
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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_HelloWorld_type_objects();

#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

/**
Expand All @@ -53,7 +48,7 @@ eProsima_user_DllExport void register_HelloWorld_type_objects();
* Invalid TypeIdentifier is returned in case of error.
*/
eProsima_user_DllExport void register_HelloWorld_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids);


#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
Expand Down
Loading
Loading