Skip to content

Commit

Permalink
TypeObjectRegistry refactor (#4874)
Browse files Browse the repository at this point in the history
* Refs #21044. Register individual structure

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Intermediate commit

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Apply suggestions from Lucia

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Regeneration of code

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Regeneration of code

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Remove TODO

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix warning on Windows

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix warning on mac and failed tests.

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix statistics tests

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix statistics tests and other things

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix doxygen

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. More TryConstructKind standard

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. More ExtensibilityKind standard

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Apply suggestions

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix building minimal for remote coplete typeobject

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Add and fixes for test BasicAnnotationsTest

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Add test UnionSeveralFields

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix compilation

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix compilation after rebase

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #21044. Fix typelookupservice generating minimal type objects

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

---------

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware authored Jun 14, 2024
1 parent 371286c commit dbab57d
Show file tree
Hide file tree
Showing 326 changed files with 47,626 additions and 235,280 deletions.
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

0 comments on commit dbab57d

Please sign in to comment.