Skip to content

Commit

Permalink
Automatic TypeObject representation registration for DynamicTypes (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
richiware authored May 20, 2024
1 parent f1d0002 commit f5bd489
Show file tree
Hide file tree
Showing 8 changed files with 2,100 additions and 3,392 deletions.
2,962 changes: 1,179 additions & 1,783 deletions fastdds_python/test/types/test_completeTypeObjectSupport.cxx

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions fastdds_python/test/types/test_completeTypeObjectSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef _FAST_DDS_GENERATED_TEST_COMPLETE_TYPE_OBJECT_SUPPORT_HPP_
#define _FAST_DDS_GENERATED_TEST_COMPLETE_TYPE_OBJECT_SUPPORT_HPP_

#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>

#include "test_included_modulesTypeObjectSupport.hpp"

#if defined(_WIN32)
Expand All @@ -46,22 +48,37 @@ eProsima_user_DllExport void register_test_complete_type_objects();
* 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.
*
* @param[out] TypeIdentifier of the registered type.
* 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_StructType_type_identifier();
eProsima_user_DllExport void register_StructType_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
/**
* @brief Register CompleteTestType 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.
*
* @param[out] TypeIdentifier of the registered type.
* 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_CompleteTestType_type_identifier();
eProsima_user_DllExport void register_CompleteTestType_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
/**
* @brief Register KeyedCompleteTestType 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.
*
* @param[out] TypeIdentifier of the registered type.
* 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_KeyedCompleteTestType_type_identifier();
eProsima_user_DllExport void register_KeyedCompleteTestType_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);


#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULES_TYPE_OBJECT_SUPPORT_HPP_
#define _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULES_TYPE_OBJECT_SUPPORT_HPP_

#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>


#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
Expand All @@ -47,8 +49,13 @@ namespace test2 {
* 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.
*
* @param[out] TypeIdentifier of the registered type.
* 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_eprosima_test2_StructType2_type_identifier();
eProsima_user_DllExport void register_eprosima_test2_StructType2_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);

} // namespace test2

Expand Down
2,374 changes: 819 additions & 1,555 deletions fastdds_python/test/types/test_modulesTypeObjectSupport.cxx

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions fastdds_python/test/types/test_modulesTypeObjectSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULES_TYPE_OBJECT_SUPPORT_HPP_
#define _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULES_TYPE_OBJECT_SUPPORT_HPP_

#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>


#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
Expand All @@ -47,8 +49,13 @@ namespace test {
* 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.
*
* @param[out] TypeIdentifier of the registered type.
* 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_eprosima_test_StructType_type_identifier();
eProsima_user_DllExport void register_eprosima_test_StructType_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);



Expand All @@ -57,16 +64,26 @@ eProsima_user_DllExport void register_eprosima_test_StructType_type_identifier()
* 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.
*
* @param[out] TypeIdentifier of the registered type.
* 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_eprosima_test_CompleteTestType_type_identifier();
eProsima_user_DllExport void register_eprosima_test_CompleteTestType_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);

/**
* @brief Register eprosima_test_KeyedCompleteTestType 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.
*
* @param[out] TypeIdentifier of the registered type.
* 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_eprosima_test_KeyedCompleteTestType_type_identifier();
eProsima_user_DllExport void register_eprosima_test_KeyedCompleteTestType_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);

} // namespace test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ void register_HelloWorld_type_objects()
static std::once_flag once_flag;
std::call_once(once_flag, []()
{
register_HelloWorld_type_identifier();
TypeIdentifier type_id;
register_HelloWorld_type_identifier(type_id);

});
}

void register_HelloWorld_type_identifier()
// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
void register_HelloWorld_type_identifier(
TypeIdentifier& type_id)
{
{
StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED,
Expand All @@ -71,6 +74,7 @@ void register_HelloWorld_type_identifier()
{
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,
Expand Down Expand Up @@ -117,6 +121,7 @@ void register_HelloWorld_type_identifier()
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"Structure index member TypeIdentifier inconsistent.");
type_id = TypeIdentifier();
return;
}
MemberName name_index = "index";
Expand All @@ -133,8 +138,6 @@ void register_HelloWorld_type_identifier()

if (return_code_HelloWorld != eprosima::fastdds::dds::RETCODE_OK)
{
std::string type_id_kind_anonymous_string_unbounded("TI_STRING8_SMALL");
if (type_id_kind_anonymous_string_unbounded == "TI_STRING8_SMALL")
{
SBound bound = 0;
StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
Expand All @@ -146,31 +149,14 @@ void register_HelloWorld_type_identifier()
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
else if (type_id_kind_anonymous_string_unbounded == "TI_STRING8_LARGE")
{
LBound bound = 255;
StringLTypeDefn string_ldefn = TypeObjectUtils::build_string_l_type_defn(bound);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_l_string_type_identifier(string_ldefn,
"anonymous_string_unbounded"))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
else
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_string_unbounded: Unknown String kind.");
return;
}
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;
}
}
Expand Down Expand Up @@ -218,6 +204,7 @@ void register_HelloWorld_type_identifier()
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"Structure message member TypeIdentifier inconsistent.");
type_id = TypeIdentifier();
return;
}
MemberName name_message = "message";
Expand All @@ -229,7 +216,7 @@ 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()))
TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_id))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"HelloWorld already registered in TypeObjectRegistry for a different type.");
Expand All @@ -241,6 +228,7 @@ void register_HelloWorld_type_identifier()
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"HelloWorld: Given Struct TypeIdentifier unknown to TypeObjectRegistry.");
type_id = TypeIdentifier();
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_
#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_

#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>


#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
Expand All @@ -45,8 +47,13 @@ eProsima_user_DllExport void register_HelloWorld_type_objects();
* 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.
*
* @param[out] TypeIdentifier of the registered type.
* 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_HelloWorld_type_identifier();
eProsima_user_DllExport void register_HelloWorld_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);


#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
Expand Down

0 comments on commit f5bd489

Please sign in to comment.