Skip to content

Commit f5bd489

Browse files
authored
Automatic TypeObject representation registration for DynamicTypes (#130)
1 parent f1d0002 commit f5bd489

8 files changed

Lines changed: 2100 additions & 3392 deletions

fastdds_python/test/types/test_completeTypeObjectSupport.cxx

Lines changed: 1179 additions & 1783 deletions
Large diffs are not rendered by default.

fastdds_python/test/types/test_completeTypeObjectSupport.hpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef _FAST_DDS_GENERATED_TEST_COMPLETE_TYPE_OBJECT_SUPPORT_HPP_
2323
#define _FAST_DDS_GENERATED_TEST_COMPLETE_TYPE_OBJECT_SUPPORT_HPP_
2424

25+
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
26+
2527
#include "test_included_modulesTypeObjectSupport.hpp"
2628

2729
#if defined(_WIN32)
@@ -46,22 +48,37 @@ eProsima_user_DllExport void register_test_complete_type_objects();
4648
* Fully-descriptive TypeIdentifiers are directly registered.
4749
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
4850
* indirectly registered as well.
51+
*
52+
* @param[out] TypeIdentifier of the registered type.
53+
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
54+
* Invalid TypeIdentifier is returned in case of error.
4955
*/
50-
eProsima_user_DllExport void register_StructType_type_identifier();
56+
eProsima_user_DllExport void register_StructType_type_identifier(
57+
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
5158
/**
5259
* @brief Register CompleteTestType related TypeIdentifier.
5360
* Fully-descriptive TypeIdentifiers are directly registered.
5461
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
5562
* indirectly registered as well.
63+
*
64+
* @param[out] TypeIdentifier of the registered type.
65+
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
66+
* Invalid TypeIdentifier is returned in case of error.
5667
*/
57-
eProsima_user_DllExport void register_CompleteTestType_type_identifier();
68+
eProsima_user_DllExport void register_CompleteTestType_type_identifier(
69+
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
5870
/**
5971
* @brief Register KeyedCompleteTestType related TypeIdentifier.
6072
* Fully-descriptive TypeIdentifiers are directly registered.
6173
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
6274
* indirectly registered as well.
75+
*
76+
* @param[out] TypeIdentifier of the registered type.
77+
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
78+
* Invalid TypeIdentifier is returned in case of error.
6379
*/
64-
eProsima_user_DllExport void register_KeyedCompleteTestType_type_identifier();
80+
eProsima_user_DllExport void register_KeyedCompleteTestType_type_identifier(
81+
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
6582

6683

6784
#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

fastdds_python/test/types/test_included_modulesTypeObjectSupport.cxx

Lines changed: 35 additions & 23 deletions
Large diffs are not rendered by default.

fastdds_python/test/types/test_included_modulesTypeObjectSupport.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULES_TYPE_OBJECT_SUPPORT_HPP_
2323
#define _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULES_TYPE_OBJECT_SUPPORT_HPP_
2424

25+
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
26+
2527

2628
#if defined(_WIN32)
2729
#if defined(EPROSIMA_USER_DLL_EXPORT)
@@ -47,8 +49,13 @@ namespace test2 {
4749
* Fully-descriptive TypeIdentifiers are directly registered.
4850
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
4951
* indirectly registered as well.
52+
*
53+
* @param[out] TypeIdentifier of the registered type.
54+
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
55+
* Invalid TypeIdentifier is returned in case of error.
5056
*/
51-
eProsima_user_DllExport void register_eprosima_test2_StructType2_type_identifier();
57+
eProsima_user_DllExport void register_eprosima_test2_StructType2_type_identifier(
58+
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
5259

5360
} // namespace test2
5461

fastdds_python/test/types/test_modulesTypeObjectSupport.cxx

Lines changed: 819 additions & 1555 deletions
Large diffs are not rendered by default.

fastdds_python/test/types/test_modulesTypeObjectSupport.hpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULES_TYPE_OBJECT_SUPPORT_HPP_
2323
#define _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULES_TYPE_OBJECT_SUPPORT_HPP_
2424

25+
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
26+
2527

2628
#if defined(_WIN32)
2729
#if defined(EPROSIMA_USER_DLL_EXPORT)
@@ -47,8 +49,13 @@ namespace test {
4749
* Fully-descriptive TypeIdentifiers are directly registered.
4850
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
4951
* indirectly registered as well.
52+
*
53+
* @param[out] TypeIdentifier of the registered type.
54+
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
55+
* Invalid TypeIdentifier is returned in case of error.
5056
*/
51-
eProsima_user_DllExport void register_eprosima_test_StructType_type_identifier();
57+
eProsima_user_DllExport void register_eprosima_test_StructType_type_identifier(
58+
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
5259

5360

5461

@@ -57,16 +64,26 @@ eProsima_user_DllExport void register_eprosima_test_StructType_type_identifier()
5764
* Fully-descriptive TypeIdentifiers are directly registered.
5865
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
5966
* indirectly registered as well.
67+
*
68+
* @param[out] TypeIdentifier of the registered type.
69+
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
70+
* Invalid TypeIdentifier is returned in case of error.
6071
*/
61-
eProsima_user_DllExport void register_eprosima_test_CompleteTestType_type_identifier();
72+
eProsima_user_DllExport void register_eprosima_test_CompleteTestType_type_identifier(
73+
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
6274

6375
/**
6476
* @brief Register eprosima_test_KeyedCompleteTestType related TypeIdentifier.
6577
* Fully-descriptive TypeIdentifiers are directly registered.
6678
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
6779
* indirectly registered as well.
80+
*
81+
* @param[out] TypeIdentifier of the registered type.
82+
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
83+
* Invalid TypeIdentifier is returned in case of error.
6884
*/
69-
eProsima_user_DllExport void register_eprosima_test_KeyedCompleteTestType_type_identifier();
85+
eProsima_user_DllExport void register_eprosima_test_KeyedCompleteTestType_type_identifier(
86+
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
7087

7188
} // namespace test
7289

fastdds_python_examples/HelloWorldExample/HelloWorldTypeObjectSupport.cxx

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ void register_HelloWorld_type_objects()
4343
static std::once_flag once_flag;
4444
std::call_once(once_flag, []()
4545
{
46-
register_HelloWorld_type_identifier();
46+
TypeIdentifier type_id;
47+
register_HelloWorld_type_identifier(type_id);
4748

4849
});
4950
}
5051

51-
void register_HelloWorld_type_identifier()
52+
// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
53+
void register_HelloWorld_type_identifier(
54+
TypeIdentifier& type_id)
5255
{
5356
{
5457
StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED,
@@ -71,6 +74,7 @@ void register_HelloWorld_type_identifier()
7174
{
7275
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
7376
"index Structure member TypeIdentifier unknown to TypeObjectRegistry.");
77+
type_id = TypeIdentifier();
7478
return;
7579
}
7680
StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED,
@@ -117,6 +121,7 @@ void register_HelloWorld_type_identifier()
117121
{
118122
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
119123
"Structure index member TypeIdentifier inconsistent.");
124+
type_id = TypeIdentifier();
120125
return;
121126
}
122127
MemberName name_index = "index";
@@ -133,8 +138,6 @@ void register_HelloWorld_type_identifier()
133138

134139
if (return_code_HelloWorld != eprosima::fastdds::dds::RETCODE_OK)
135140
{
136-
std::string type_id_kind_anonymous_string_unbounded("TI_STRING8_SMALL");
137-
if (type_id_kind_anonymous_string_unbounded == "TI_STRING8_SMALL")
138141
{
139142
SBound bound = 0;
140143
StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
@@ -146,31 +149,14 @@ void register_HelloWorld_type_identifier()
146149
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
147150
}
148151
}
149-
else if (type_id_kind_anonymous_string_unbounded == "TI_STRING8_LARGE")
150-
{
151-
LBound bound = 255;
152-
StringLTypeDefn string_ldefn = TypeObjectUtils::build_string_l_type_defn(bound);
153-
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
154-
TypeObjectUtils::build_and_register_l_string_type_identifier(string_ldefn,
155-
"anonymous_string_unbounded"))
156-
{
157-
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
158-
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
159-
}
160-
}
161-
else
162-
{
163-
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
164-
"anonymous_string_unbounded: Unknown String kind.");
165-
return;
166-
}
167152
return_code_HelloWorld =
168153
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
169154
"anonymous_string_unbounded", type_ids_HelloWorld);
170155
if (return_code_HelloWorld != eprosima::fastdds::dds::RETCODE_OK)
171156
{
172157
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
173158
"anonymous_string_unbounded: Given String TypeIdentifier unknown to TypeObjectRegistry.");
159+
type_id = TypeIdentifier();
174160
return;
175161
}
176162
}
@@ -218,6 +204,7 @@ void register_HelloWorld_type_identifier()
218204
{
219205
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
220206
"Structure message member TypeIdentifier inconsistent.");
207+
type_id = TypeIdentifier();
221208
return;
222209
}
223210
MemberName name_message = "message";
@@ -229,7 +216,7 @@ void register_HelloWorld_type_identifier()
229216
}
230217
CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld);
231218
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
232-
TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string()))
219+
TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_id))
233220
{
234221
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
235222
"HelloWorld already registered in TypeObjectRegistry for a different type.");
@@ -241,6 +228,7 @@ void register_HelloWorld_type_identifier()
241228
{
242229
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
243230
"HelloWorld: Given Struct TypeIdentifier unknown to TypeObjectRegistry.");
231+
type_id = TypeIdentifier();
244232
return;
245233
}
246234
}

fastdds_python_examples/HelloWorldExample/HelloWorldTypeObjectSupport.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_
2323
#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_
2424

25+
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
26+
2527

2628
#if defined(_WIN32)
2729
#if defined(EPROSIMA_USER_DLL_EXPORT)
@@ -45,8 +47,13 @@ eProsima_user_DllExport void register_HelloWorld_type_objects();
4547
* Fully-descriptive TypeIdentifiers are directly registered.
4648
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
4749
* indirectly registered as well.
50+
*
51+
* @param[out] TypeIdentifier of the registered type.
52+
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
53+
* Invalid TypeIdentifier is returned in case of error.
4854
*/
49-
eProsima_user_DllExport void register_HelloWorld_type_identifier();
55+
eProsima_user_DllExport void register_HelloWorld_type_identifier(
56+
eprosima::fastdds::dds::xtypes::TypeIdentifier& type_id);
5057

5158

5259
#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

0 commit comments

Comments
 (0)